https://leetcode.com/problems/valid-phone-numbers/description/
^ start with
$ end with
basic regex
( { | are regular characters matching ( { |
\( \{ \| ... are special operations
grep '^\([0-9]\{3\}-\|([0-9]\{3\}) \)[0-9]\{3\}-[0-9]\{4\}$' file.txt
extended regex
( { | are special operations
\( \{ \| ... are escape characters matching ( { |
grep -E '^([0-9]{3}-|\([0-9]{3}\) )[0-9]{3}-[0-9]{4}$' file.txt
No comments:
Post a Comment