how can i delete every word in a text file except a word?

minamon

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}]}

barlop

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.

Say you have enter image description here

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)

enter image description here

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I delete the 5th word of every line in a file?

From Dev

How can I delete from a file every second and fourth comma separated word using sed?

From Dev

How can I use the ".title() command to read a text file and capitalize every word in the file?

From Dev

How can I append an incremental count to every predefined word of a text file?

From Dev

How can I assign a numerical value to every word in a text file or user input in java

From Dev

how can i underline a text word by word?

From Dev

How can I have different text in the footer on every page of a Word document?

From Dev

How can I change the color of text in Word

From Dev

How can I delete, break, unlink, or otherwise convert cross references to simple text in microsoft word 2013

From Dev

How can I batch rename text files to be the first word in each text file?

From Dev

How can I delete everything after a word from multiple line in a file

From Java

How can I replace the first occurrence of a character in every word?

From Dev

How can I replace the first occurrence of a character in every word?

From Dev

RegExp for every word except first word of a sentence

From Dev

To find frequency of every word in text file in python

From Dev

Count every word in a text file python

From Dev

To find frequency of every word in text file in python

From Dev

How can I obtain only word without All Punctuation Marks when I read text file?

From Dev

How to find a word in a text file and delete the line containing the word and the next two lines?

From Dev

How can I delete a word backward at the command line (bash and zsh)?

From Dev

How can I delete a word from a String in Visual C#

From Dev

How can I account for varying word lengths in a program that replaces words read from a text file?

From Dev

Using StringBuilder and BufferedReader, how can I add commas after each word in a text file and produce a string?

From Dev

How can I add text to a file in front of a specific word from the Linux command line?

From Dev

How can I find the n-th '<' symbol containing word in an XML-like text file?

From Dev

How can I save text from bash output which starts with a specific word in a file?

From Dev

Search for a word in a text-file and delete segments containing this word

From Dev

Delete word from a line in a text file

From Dev

Delete specific pattern in a word from a Text file

Related Related

  1. 1

    How can I delete the 5th word of every line in a file?

  2. 2

    How can I delete from a file every second and fourth comma separated word using sed?

  3. 3

    How can I use the ".title() command to read a text file and capitalize every word in the file?

  4. 4

    How can I append an incremental count to every predefined word of a text file?

  5. 5

    How can I assign a numerical value to every word in a text file or user input in java

  6. 6

    how can i underline a text word by word?

  7. 7

    How can I have different text in the footer on every page of a Word document?

  8. 8

    How can I change the color of text in Word

  9. 9

    How can I delete, break, unlink, or otherwise convert cross references to simple text in microsoft word 2013

  10. 10

    How can I batch rename text files to be the first word in each text file?

  11. 11

    How can I delete everything after a word from multiple line in a file

  12. 12

    How can I replace the first occurrence of a character in every word?

  13. 13

    How can I replace the first occurrence of a character in every word?

  14. 14

    RegExp for every word except first word of a sentence

  15. 15

    To find frequency of every word in text file in python

  16. 16

    Count every word in a text file python

  17. 17

    To find frequency of every word in text file in python

  18. 18

    How can I obtain only word without All Punctuation Marks when I read text file?

  19. 19

    How to find a word in a text file and delete the line containing the word and the next two lines?

  20. 20

    How can I delete a word backward at the command line (bash and zsh)?

  21. 21

    How can I delete a word from a String in Visual C#

  22. 22

    How can I account for varying word lengths in a program that replaces words read from a text file?

  23. 23

    Using StringBuilder and BufferedReader, how can I add commas after each word in a text file and produce a string?

  24. 24

    How can I add text to a file in front of a specific word from the Linux command line?

  25. 25

    How can I find the n-th '<' symbol containing word in an XML-like text file?

  26. 26

    How can I save text from bash output which starts with a specific word in a file?

  27. 27

    Search for a word in a text-file and delete segments containing this word

  28. 28

    Delete word from a line in a text file

  29. 29

    Delete specific pattern in a word from a Text file

HotTag

Archive