More Basic Regular Expressions: Matching an Email Address

30 minutes
  • 2 Learning Objectives

About this Hands-on Lab

As our knowledge and experience with regular expressions grows, we can begin to match more and more generalized items, such as an email address. By coming up with the regex to match an email address, we need to use concepts such as grouping, ranges, repetition, literal characters, and more. This learning activity also expects you to have some knowledge of `grep` and `sort`.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create an `emails.txt` file.

Create an emails.txt file containing an ordered list of all customer emails.

Match all emails in `customer-data.txt`.

Use grep and a regular expression to match all the emails in the customer-data.txt file.

Additional Resources

You work for Ethercloud, a web hosting company. Due to scheduled downtime, the support team needs a list of email addresses so that they can contact customers appropriately. Since you have access to a CSV of customer data (customer-data.xt), you've been tasked with retrieving all emails from this data via regular expression and sorting them in alphabetical order. (Hint: Use grep and sort.)

While writing the regular expression, note the following restrictions regarding email address:

  • The local-part (or username), can use any alphanumeric character or one of the following: <code>! # $ % & ' * + - / = ? ^ _ ` { | } ~ .</code>
  • The second-level domain (gmail in gmail.com) must begin with an alphanumeric character but any character after that can also contain a dash (-).
  • The domain must be at least one character long.
  • The top-level domain (such as com) must only use alphanumeric characters.
  • The top-level domain must be between two and 63 characters.

If you need a list of email addresses to match, try:

test_email@linuxacademy.com
panel.80432@outlook.com
Beauty-90184@yahoo.com
RusticPlasticSausages13@yahoo.com
Facet-o-face29917@yahoo.com
What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!
Thanks for reaching out!

You’ll hear from us shortly. In the meantime, why not check out what our customers have to say about ACG?