I’ve got many html-docs that need selective replacement of the <br /> tag in two specific areas in each document (400+).
I wonder how to achieve this goal and need assistance.
In each HTML-document the <br />-tag needs to be replaced only inside the html-tag:
<span property="dc:description" content="xyz1,<br /> xyz2,<br /> xyz3"/>
and also all occurences of <br />inside the alt="-tag, like in the html-tag
<img src="xyz.jpg" alt="uvw1,<br />uvw2" />)
In all other areas of the HTML-Docs the <br />-tag must remain unchanged.
…I gave this some more thought and think the problem described above may be resolved with the aid of a script or a function equipped with start- and stop-signals. This way the script knows at which positions to start looking for the <br />-tag and replace it with a given text-string AND also knows where to stop. Then move on to the next instance in documents that are open in an editor or residing in a given folder.
I am afraid that I am not capable to write such a script myself.
Hope someone can provide feedback on how to best accomplish this,
thanks.
OS: Win7-64, Editor: Notepad++
Providing that your HTML files aren’t really big, I don’t think you need a script for this.
You could just:
<span([^/]*)<br />(.*)"/>with<span\1NEWTAG\2"/>whereNEWTAGis whatever you want to replace the<br />with. Note that this will only replace the first<br />it finds each time, so you will need to do this a few times until it finds no more. Therefore if you’re replacing with text that contains<br />itself (which I doubt by the sounds of it), you’ll need to modify this a little.Personally I’d just write a Python script, as it’s pretty ace at string manipulation. But I don’t know if this is within your scope.