Extracting text between tags

Tool for Search and Replace across multiple files.
Post Reply
imperial
Posts: 2
Joined: Sun Oct 27, 2013 6:45 am

Extracting text between tags

Post by imperial »

Firstly thank you so much for this tool and thank you for making it free :D

I have a quick question, I have a whole heap of text files and I need to extract text that sits between two tags (html) I then need this extracted text to be saved to files (each indivdual file has the same tags but the text in between is different).

I have done regular expression <tagname>[\s\S]*</tagname>

And this works great as it selects the text in between the tags from each file, however I am stuck as what to do next?

Any help would be greatly appreciated.
User avatar
DigitalVolcano
Site Admin
Posts: 1731
Joined: Thu Jun 09, 2011 10:04 am

Re: Extracting text between tags

Post by DigitalVolcano »

The current version doesn't support writing just the found text to a new file. (Hopefully next version?)

However you could possibly do this by making a backup copy of your files, then running a search for .*<tagname> and replacing with nothing, and then repeating this for </tagname>.* and replacing with nothing. ("Dot matches newline" option turned on) This will strip out everything except the text between tags. Of course this assumes you only have one tag per file...
imperial
Posts: 2
Joined: Sun Oct 27, 2013 6:45 am

Re: Extracting text between tags

Post by imperial »

DigitalVolcano wrote:The current version doesn't support writing just the found text to a new file. (Hopefully next version?)

However you could possibly do this by making a backup copy of your files, then running a search for .*<tagname> and replacing with nothing, and then repeating this for </tagname>.* and replacing with nothing. ("Dot matches newline" option turned on) This will strip out everything except the text between tags. Of course this assumes you only have one tag per file...
No problems
Yeh I thought of doing this last night, I will give it a shot, thanks for the reply :D
Post Reply