I'm trying to delete a single meta tag line of code from an html file.
The line of code starts with <meta name="topic-breadcrumbs". It can be in either of these forms:
<meta name="topic-breadcrumbs" content="PC-DMIS Hilfe-Kerndatei > Definieren von Hardware > Definieren von Tasterwechslern > Registerkarte Kalibrieren > Kalibrieren des Tasterwechslers ACR3" />
or:
<meta name="topic-breadcrumbs" content="PC-DMIS Hilfe-Kerndatei > Definieren von Hardware > Definieren von Tasterwechslern > Registerkarte Kalibrieren > Kalibrieren des Tasterwechslers ACR3" /><script type="text/javascript" language="JavaScript">
For the second example, I want to delete only the meta tag, leaving the line for the script in place.
This is just one example. each meta tag line will be different as the "content" in the tag refers to chapters and there are hundreds of chapters which is why I want to just capture the opening of the meta tag line of code (<meta name="topic-breadcrumbs") since that will always be the same and then the closing characters />.
I have hundreds of html files that I need to delete this line from. Is there a way using regular expressions in NP to automate this? I've looked at several examples here as well as in other forums but I have not found anything specific to my needs.
I would like to match the opening line of the code <meta name="topic-breadcrumbs" and then to the first instance of the meta tag's closing />.
Thanks!
CodePudding user response:
I assume you have all files in one directory or subfolders. Please think about a backup copy for your test!
- Open one file in your workspace
- Open the dialog e.g. by STRG F
- Try for your needs Find What:
(^<meta name="topic-breadcrumbs" content=". \" \/>)
- Choose Regular Expression (be careful, later (!) give a try and test
match newline
) - Open Find in Files tab e.g. by STRG Shift F
- Replace with:
Nothing
- Set Filter
- Set Directory
- First press Find All and check the results
- Press Replace in Files (at your own risk!)
Before:
After: