My solution using Bash and P flag

interview-questions
Tags: #<Tag:0x00007f243555d268>

#1

My easy solution to the problem using Bash I have used -P flag with grep
grep -P ‘^(\d{3}-|(\d{3}) )\d{3}-\d{4}$’ input