Created
January 6, 2019 01:44
-
-
Save frankhu-2021/c94ee5589f68416cc104d3dbe2efc9b5 to your computer and use it in GitHub Desktop.
Regex for Phone numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. xxx-xxx-xxxx grep -o '[0-9]\{3\}\-[0-9]\{3\}\-[0-9]\{4\}' file.txt | |
2. (xxx)xxx-xxxx grep -o '([0-9]\{3\})[0-9]\{3\}\-[0-9]\{4\}' file.txt | |
3. xxx xxx xxxx grep -o '[0-9]\{3\}\s[0-9]\{3\}\s[0-9]\{4\}' file.txt | |
4. xxxxxxxxxx grep -o '[0-9]\{10\}' file.txt | |
grep -o '\([0-9]\{3\}\-[0-9]\{3\}\-[0-9]\{4\}\)\|\(([0-9]\{3\})[0-9]\{3\}\-[0-9]\{4\}\)\|\([0-9]\{10\}\)\|\([0-9]\{3\}\s[0-9]\{3\}\s[0-9]\{4\}\)' file.txt | |
- Found online, and put on my git for reference. | |
Credit goes to Raullen Chai | |
on | |
http://stackoverflow.com/questions/2269586/grep-with-regex-for-phone-number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment