193. Valid Phone Numbers
UnknownView on LeetCode
Advertisement
About this solution
Valid Phone Numbers is a unknown-difficulty LeetCode problem covering the Shell pattern. The Shell solution below uses an idiomatic approach that is clean, readable, and directly submittable on LeetCode. Study the logic carefully — recognising the underlying pattern is the key skill that transfers to similar problems in interviews.
Key Techniques
193.sh
Shell
# Read from the file file.txt and output all valid phone numbers to stdout.
grep -e "^[0-9]\{3\}\-[0-9]\{3\}\-[0-9]\{4\}$" -e "^([0-9]\{3\}) [0-9]\{3\}\-[0-9]\{4\}$" file.txtAdvertisement
Was this solution helpful?