-1

I need to replace all periods in a user submitted paragraph of text that will most likely be copy and pasted from a microsoft word document so the text will have formatting on it.

For example, text pasted in from word looks like this:

<p class="MsoNormal" style="margin-bottom: 5.75pt; text-indent: 0.5in;"><span style="font-size:12.0pt;font-family: etc...

I need to edit all of the periods not within these tags and put span tags around them, so I can't just grab the html and do .replace.

:(

Dennis
  • 32,200
  • 11
  • 64
  • 79
Clinton Jooooones
  • 887
  • 3
  • 12
  • 19

1 Answers1

0

Use this answer to find text nodes, then do the replace on them.

If you have it as a string, convert into document fragment first.

Community
  • 1
  • 1
Amadan
  • 191,408
  • 23
  • 240
  • 301