基础匹配
来源:互联网 发布:类似基督山伯爵 知乎 编辑:程序博客网 时间:2024/05/15 06:33
193. Valid Phone Numbers
Given a text file file.txt
that contains 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)
You may also assume each line in the text file must not contain leading or trailing white spaces.
For example, assume that file.txt
has the following content:
987-123-4567123 456 7890(123) 456-7890Your script should output the following valid phone numbers:
987-123-4567(123) 456-7890
如下是用awk命令写的:
awk '{if($0 ~ /(^[0-9]{3}\-[0-9]{3}\-[0-9]{4}$)|(^\([0-9]{3}\) [0-9]{3}\-[0-9]{4}$)/ ) print $0}' file.txt
阅读全文
0 0
- 基础匹配
- hdu2063二分匹配基础
- hdu1151二分匹配基础
- hdu1083二分匹配基础
- OpenCV基础05(匹配)
- c++基础--函数匹配
- hdu2063二分匹配基础
- scala基础-模式匹配
- 正则表达式基础字符匹配
- 数据结构基础+STL--符号匹配
- HDU2063 二分匹配基础题目
- SQL基础(一二)--- 匹配
- Python基础学习----正则匹配
- 匹配电话号码(基础代码)
- MQTT topic匹配规则基础
- hdu2063(二分匹配基础)
- POJ3461-字符串匹配(基础)
- Spark基础-Scala模式匹配
- hdoj 1173 采矿
- 编写第一个Android程序
- OAuth 2.0 MAC Tokens
- 重载new/delete自定义内存管理
- 【机器学习系列之三】特征工程
- 基础匹配
- 自测02—素数对猜想
- 《java与模式》-7 工厂模式
- 如何输出TOMCAT的配置参数
- Java开发中的23种设计模式详解(转)
- 10.28-10.29总结(HTML结构&CSS)
- CodeForces
- python笔记008--python的相关模块和开发工具
- NOIP模拟(10.31)T1 机器清洁工