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.
Example:
Assume that file.txt
has the following content:
- 987-123-4567
- 123 456 7890
- (123) 456-7890
Your script should output the following valid phone numbers:
- 987-123-4567
- (123) 456-7890
- 在文本中找出(xxx) xxx-xxxx or xxx-xxx-xxxx 这样的字符串
- grep -e '^[0-9]\{3\}-[0-9]\{3\}-[0-9]\{4\}$' -e '^([0-9]\{3\}) [0-9]\{3\}-[0-9]\{4\}$' file.txt
193 Valid Phone Numbers的更多相关文章
- LeetCode(193. Valid Phone Numbers)(sed用法)
193. Valid Phone Numbers Given a text file file.txt that contains list of phone numbers (one per lin ...
- LeetCode 193. Valid Phone Numbers
分析 难度 易 来源 https://leetcode.com/problems/valid-phone-numbers/ 题目 Given a text file file.txt that con ...
- [LeetCode] Valid Phone Numbers 验证电话号码
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...
- Valid Phone Numbers
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...
- [Bash]LeetCode193. 有效电话号码 | Valid Phone Numbers
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...
- [LeetCode] 193. Valid Phone Numbers_Easy tag: Bash
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...
- LeetCode All in One 题目讲解汇总(持续更新中...)
终于将LeetCode的免费题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 477 Total Hamming Distance ...
- LeetCode Shell Problems
195. Tenth Line -- 第十行 How would you print just the 10th line of a file? Solution: awk 'NR==10' file ...
- 【LeetCode】shell
195. Tenth Line 输出file.txt中的第十行 答案: # Read from the file file.txt and output the tenth line to stdou ...
随机推荐
- CF86D Powerful array
题意翻译 题意:给出一个n个数组成的数列a,有t次询问,每次询问为一个[l,r]的区间,求区间内每种数字出现次数的平方×数字的值 的和. 输入:第一行2个正整数n,t. 接下来一行n个正整数,表示数列 ...
- Gym 100463A Crossings (树状数组 逆序对)
Crossings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463 Description ...
- photoshop cc 2018破解补丁(pscc2018注册机) 附使用方法
1.下载破解程序 破解文件自行到 http://www.ddooo.com/softdown/109954.htm 下载 博主可以到本博客的文件-->pscc2018zcj_109954.ra ...
- 【刷题】BZOJ 4391 [Usaco2015 dec]High Card Low Card
Description Bessie the cow is a huge fan of card games, which is quite surprising, given her lack of ...
- oracle递归查询(查询条件ID下得所有子集)
一.CREATE TABLE TBL_TEST ( ID NUMBER, NAME VARCHAR2(100 BYTE), PID NUMBER ...
- (转)java中使用memcache
背景:公司项目中使用java和memcache相结合来搭建缓存,所以要了解下缓存的基础知识! 1 了解memcache 1.1 基础知识 什么是Memcache? Memcache集群环境下缓存解决方 ...
- 神奇:java中float,double,int的值比较运算
float x = 302.01f; System.out.println(x == 302.01); //false System.out.println(x == 302.01f); // ...
- @RequestParam注解一般用法
原文链接:https://www.cnblogs.com/likaileek/p/7218252.html SpringMVC注解@RequestParam全面解析 在此之前,写项目一直用的是@R ...
- OpenStack 图形化服务 Horizon使用(十三)
构建一台云主机 上图中Count可以选择同时创建多台 最终“启动实例” 创建成功后,可以进入控制台,操作新建云主机
- 20181103 Nginx(布尔教育)
nginx介绍 对标Apache服务器 目录介绍 conf 配置文件 html 网页文件 logs 日志文件 sbin 主要二进制程序 控制命令 ./nginx # 启动 nginx -t # 测试配 ...