193. Valid Phone Numbers bash正则
描述
输入
987-123-4567
123 456 7890
(123) 456-7890
输出
987-123-4567
(123) 456-7890
正则匹配过滤。
grep -E '^([0-9]{3}-|\([0-9]{3}\) )[0-9]{3}-[0-9]{4}$ file.txt'
grep -E
表示通过正则过滤文本。^
匹配开始$
匹配结尾|
条件或
关键是匹配头尾。
描述
输入
987-123-4567
123 456 7890
(123) 456-7890
输出
987-123-4567
(123) 456-7890
正则匹配过滤。
grep -E '^([0-9]{3}-|\([0-9]{3}\) )[0-9]{3}-[0-9]{4}$ file.txt'
grep -E
表示通过正则过滤文本。^
匹配开始$
匹配结尾|
条件或
关键是匹配头尾。
![在这里插入图片描述][20191113061029181.jpeg_pic_center_pic_center] sed和grep -o可以用来提取相应的内容,结合正则
给定一个包含电话号码列表(一行一个电话号码)的文本文件 file.txt,写一个 bash 脚本输出所有有效的电话号码。 你可以假设一个有效的电话号码必须满足以下两种格式:
Topic Bash Description [https://leetcode.com/problems/valid-phone-numbers/][ht
Phone Number Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^\_^ 题目描述 We kn
193. Valid Phone Numbers Question Editorial Solution [My Submissions][] Tot
描述 输入 987-123-4567 123 456 7890 (123) 456-7890 输出 987-123-4567 (123) 456-7
Given a digit string, return all possible letter combinations that the number could repr
Validate if a given string is numeric. Some examples: `"0"` => `true` `" 0.1 "` =>
还没有评论,来说两句吧...