Regex to only keep email:password
Solution 1:
This will match email only after EmailPass :
- Ctrl+H
- Find what:
.+?EmailPass : (\S+@\S+)
- Replace with:
$1\n
- UNCHECK Match case
- CHECK Wrap around
- CHECK Regular expression
-
CHECK
. matches newline
- Replace all
Explanation:
.+? # 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
Replacement:
$1 # content of group 1, the email
\n # a linebreak, you can use \r\n for Windows EOL
Screenshot (before):
Screenshot (after):
Solution 2:
This only matches correct emails (emails, containing @
and .
and text from sides and between). It also ensures that after the :
there is a password provided.
(?s).*?(\S+@\S+\.\S+:\S+)|.+
Replace with \1\n
Input example:
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$£*!
Result:
[email protected]:password222$£*!
[email protected]:password333$£*!
Demo