{ "data": { "question": { "questionId": "193", "questionFrontendId": "193", "boundTopicId": null, "title": "Valid Phone Numbers", "titleSlug": "valid-phone-numbers", "content": "
Given a text file file.txt
that contains a list of phone numbers (one per line), write a one-liner bash script to print all valid phone numbers.
You may assume that a valid phone number must appear in one of the following two formats: (xxx) xxx-xxxx or xxx-xxx-xxxx. (x means a digit)
\n\nYou may also assume each line in the text file must not contain leading or trailing white spaces.
\n\nExample:
\n\nAssume that file.txt
has the following content:
\n987-123-4567\n123 456 7890\n(123) 456-7890\n\n\n
Your script should output the following valid phone numbers:
\n\n\n987-123-4567\n(123) 456-7890\n\n", "translatedTitle": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Easy", "likes": 259, "dislikes": 693, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "0", "categoryTitle": "Shell", "contributors": [], "topicTags": [ { "name": "Shell", "slug": "shell", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "Bash", "langSlug": "bash", "code": "# Read from the file file.txt and output all valid phone numbers to stdout.\n", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"54.5K\", \"totalSubmission\": \"211.5K\", \"totalAcceptedRaw\": 54548, \"totalSubmissionRaw\": 211471, \"acRate\": \"25.8%\"}", "hints": [], "solution": null, "status": null, "sampleTestCase": "0", "metaData": "{\n \"shell\": true,\n \"manual\": true\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [], "enableRunCode": false, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"bash\": [\"Bash\", \"
Bash 4.3.30
.