1

I've got many HTML files in a folder, for each file I want to replace n-dash and m-dash with linefeed or paragrah mark, but only for specific html class.

For example, I would like to find/replace only text in class "Center". Original:

 class=Center <p class="Center">&laquo; Sentence1 &mdash; Sentence2 &ndash; Sentence3</p>
 class=Aligned <p class="Aligned">&laquo;Other Sentence4 &mdash; Other Sentence5 &ndash; OtherSentence6&laquo;</p>

Desired result:

<p class="Center">&laquo; Sentence1 </p><p></p><p> Sentence2 </p><p></p><p> Sentence3&laquo;</p>
<p class="Aligned">&laquo;Other Sentence4 &mdash; Other Sentence5 &ndash; OtherSentence6&laquo;</p>

So far I'm using this solution by Helen: https://stackoverflow.com/a/1758239/5471234

But implementing this "strText = Replace(strText, "&ndash;", "< /p>< p>< /p>< p>")" performs F/R in the whole text.

How can I limit it to class=Center? Any way to use RegEx? and/or html object .innerText to grab only specific class?

Community
  • 1
  • 1
Ainars
  • 11
  • 3
  • > "Any way to use RegEx?" The definitive answer to that one is [here](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454). – WinTakeAll Feb 23 '16 at 05:56

0 Answers0