Shell


  • 0
    D

    Read from the file file.txt and output all valid phone numbers to stdout.

    #!/bin/bash
    grep -P '^(\d{3}-||(\d{3}) )\d{3}-\d{4}$' file.txt

    关键在于正则表达式


Log in to reply
 

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