I have a file with a bunch of info of street and WIFI(s).so i want to delete every word in the text file except ,password:********, and there is a lot of it and the word after password is variable/random word a line with the word that i want to keep/copy
1499904000,::13148748,password:20022003,:1481477952,:Saad Al Ssaoudy,:7942242}]}
step 1-
find-.*?(?=password:)(password.*?)(?=(,|\s))
replace with- \r\n\r\n$1\r\n\r\n
Some explanation- this part of the find, .*?(?=password:)
matches up to a point where it can lookahead i.e. immediately to the right of the cursor, and see the word password: to the right of the cursor. Then you have this part of the find, (password.*?)
it matches and captures the word password up to, what will be mentioned next. Then you have this part of the find (?=(,|\s))
which says lookahead i.e. to immediately to the right of the cursor, for a comma or some whitespace like a space or end of line. So when you look at (password.*?) The .*?
part of it will go up to that point.
note that I ticked dot matches new line when doing that regex, as the pic on imgur shows. And notice in the pic above there are 4 passwords.
Running that find/replace, produces the following (image below)
Step 2
Then one only has to remove empty lines, in notepad++ one can do edit..line operations..remove empty lines
Any text editor with regex support is fine, e.g., Notepad++
Note- an earlier revision had a simpler regex that didn't deal sensibly with the string occurring multiple times(e.g. it would have just shown the last). This solution provides all the times the string occurs.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments