LeetCode – Valid Phone Numbers (#193) in Bash

Cover Image for LeetCode – Valid Phone Numbers (#193) in Bash
William Forty
William Forty

Today I work through problem #193 on LeetCode using Bash as the language of choice.

Code:

egrep -o "^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$" file.txt