From the course: Bash Patterns and Regular Expressions

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Solution: Create a regex to find telephone numbers

Solution: Create a regex to find telephone numbers - Bash Tutorial

From the course: Bash Patterns and Regular Expressions

Solution: Create a regex to find telephone numbers

(pulsing digital music) - [Instructor] In this challenge we parse the contacts.csv file in the Chapter 06 directory using grep, and print out the telephone numbers on the screen. My extended regular expression handles 10-digit numbers in the format of three digits hyphen three digits hyphen followed by four more digits. So it matches numbers like 907-870-5536. It also handles the area code in parentheses. It also handles international numbers that are prefixed by a plus symbol, and lastly it handles international numbers prefixed by a plus symbol, and the area code in parentheses.

Contents