
請有人幫我解決以下正規表示式。
我只想保留電話號碼並刪除其餘線路。
Name: Text here
DOB: Text here
Address: Text here
Tel: 1234 567890
我想要的是:
1234 567890
(不含「電話」)
答案1
- Ctrl+H
- 找什麼:
\A.*Tel: ([\d\h]+)|.*?
- 用。
$1
- 查看 相符
- 查看 環繞
- 查看 正規表示式
- 查看
. matches newline
- Replace all
解釋:
\A # beginning of file
.* # 0 or more any character
Tel: # literally
([\d\h]+) # group 1, 1 or more digit or space
| # OR
.*? # 0 or more any character, not greedy
替代品:
$1 # content of group 1, the phone number
截圖(之前):
截圖(之後):