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?

1
  • > "Any way to use RegEx?" The definitive answer to that one is here. Commented Feb 23, 2016 at 5:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.