mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			653 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			653 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给定一个包含电话号码列表(一行一个电话号码)的文本文件 <code>file.txt</code>,写一个单行 bash 脚本输出所有有效的电话号码。</p>
 | 
						||
 | 
						||
<p>你可以假设一个有效的电话号码必须满足以下两种格式: (xxx) xxx-xxxx 或 xxx-xxx-xxxx。(x 表示一个数字)</p>
 | 
						||
 | 
						||
<p>你也可以假设每行前后没有多余的空格字符。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例:</strong></p>
 | 
						||
 | 
						||
<p>假设 <code>file.txt</code> 内容如下:</p>
 | 
						||
 | 
						||
<pre>
 | 
						||
987-123-4567
 | 
						||
123 456 7890
 | 
						||
(123) 456-7890
 | 
						||
</pre>
 | 
						||
 | 
						||
<p>你的脚本应当输出下列有效的电话号码:</p>
 | 
						||
 | 
						||
<pre>
 | 
						||
987-123-4567
 | 
						||
(123) 456-7890
 | 
						||
</pre>
 |