My answer (numerous trials....)


  • 0
    A

    sed -rn '/^[0-9]{3}-[0-9]{3}-[0-9]{4}$|^([0-9]{3}) [0-9]{3}-[0-9]{4}$/p' file.txt


  • 0
    C

    sed -rn '/^[0-9]{3}-[0-9]{3}-[0-9]{4}$|^([0-9]{3}) [0-9]{3}-[0-9]{4}$/p' file.txt

    '' is needed before '(' and ')'


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.