-1

I need a pure regex solution, as it will be used with findAndReplaceDomText which

searches for regular expression matches in a given DOM node and replaces or wraps each match with a node or piece of text that you can specify.

If I have a string that has the word "red" occur n times in it. I want to be able to find the nth occurrence in the string.

Find "red" at 3rd occurrence should find bolded string:

For example

Alfred the Red Baron, loved autumn for its red auburn colors. But Alfred was sad as he no longer had red to paint the red auburn colors.

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
David G
  • 1
  • 1

0 Answers0