メールアドレスとパスワードのみを保持する正規表現

メールアドレスとパスワードのみを保持する正規表現

メールアドレスとパスワードだけを残して、他の情報はすべて削除したいです。

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$£*!

デモ

関連情報