
我只想保留電子郵件和密碼並刪除所有其他資訊。
Name: Test1 Test1
Address: 11 Test Road
Country : Test1
Post Code: abc111
EmailPass : [email protected]:password111$£*!
Name: Test2 Test2
Address: 22 Test Road
Country : Test2
Post Code: abc222
EmailPass : [email protected]:password222$£*!
我想要的是:
[email protected]:password111$£*!
[email protected]:password222$£*!
答案1
這將匹配電子郵件僅有的後EmailPass :
- Ctrl+H
- 找什麼:
.+?EmailPass : (\S+@\S+)
- 用。
$1\n
- 取消選取 相符
- 查看 環繞
- 查看 正規表示式
- 查看
. matches newline
- Replace all
解釋:
.+? # 1 or more any character, not greedy
EmailPass : # literally
( # group 1
\S+ # 1 or more non space
@ # @
\S+ # 1 or more non space
) # end group
替代品:
$1 # content of group 1, the email
\n # a linebreak, you can use \r\n for Windows EOL
截圖(之前):
截圖(之後):
答案2
這只匹配正確的電子郵件(包含@
和.
以及兩側和之間的文字的電子郵件)。它還確保在之後:
提供密碼。
(?s).*?(\S+@\S+\.\S+:\S+)|.+
用。\1\n
輸入範例:
Post Code: abc111
EmailPass : [email protected]:password222$£*!
Post Code: abc222
EmailPass : test_222@gmail.:password222$£*!
Post Code: abc111
EmailPass : [email protected]:
Post Code: abc111
EmailPass : [email protected]:password333$£*!
結果:
[email protected]:password222$£*!
[email protected]:password333$£*!