Tuesday, 29 August 2017

regex - Export all regular expression matches in Textpad or Notepad++ as a list


In Textpad or Notepad++ is there an option to export all the matches for a regular expression find, as a single list?


In a big text file, I am searching for tags (words enclosed in % %), using regular expression %\< and \>%, and want all the matches as a single list, so that I can remove duplicates using Excel and get a list of unique tags.



Answer



You can achieve this by using Backreferences and Find and Mark functionality in Notepad++.




  1. Find the matches using regex (say %(.*?)% ) and replace it by \n%\1%\n , after this we will have our target word in separate lines (i.e. no line will have more than one matched word)




  2. Use the Search-->Find-->Mark functionality to mark each line with regex %(.*?)% and remember to tick 'Bookmark Line' before marking the text



  3. Select Search-->Bookmark-->Remove Unmarked Lines

  4. Save the remaining text. It is the required list.


No comments:

Post a Comment

Where does Skype save my contact&#39;s avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...