Answer the question
In order to leave comments, you need to log in
How to automatically delete a piece of code in many html files, given that it is different in each individual file?
I have 39 thousand html files, I need to leave only one piece of code in them, and delete the rest of the code. How to do this automatically, given that the piece of code that needs to be left is different in each individual html file (by the way, it is enclosed in a tag ), so is the code that needs to be deleted also different in each individual file?
In short, the task boils down to this: you need to remove the code before the opening tag and remove the code after the closing tag . The code to be left is enclosed in tags . All this needs to be done automatically, in batches.
I hope I explained clearly) <article>
<article>
</article>
<article>
Answer the question
In order to leave comments, you need to log in
If you have one pair of tags <article>
, then everything is quite simply solved using regular expressions.
Trim everything before <article>
like this: 's/.+<article>/<article>/'
Trim everything after </article>
like this: 's/<\/article>.+/<\/article>/'
Recursively go through folders like this
https://stackoverflow.com/questions/6758963/find-a...
Many thanks to everyone for the help. It turned out to process all 39 thousand files through Notepad ++, through these commands$1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question