As you can see, the first and third <p> are fine. But the rest aren`t.
The second is the matched value of {form 2} but didn't enter in the replace function.
The forth is only part of the matched value of {form 1:3} and also didn't enter in the function.
And the last did enters in the replace function but the match is "";
I have this string:
let text = "{form 1} {form 2} {form 1:3}";
and this regexp:
/{form (\d+(:\d+)?)}/g
that should match {form x} and {form x:y}I am executing:
text = reactStringReplace(text, /{form (\d+(:\d+)?)}/g, (match, i) => { return 'match: ${match}, i: ${i}'; });
then in the return of my component I have this:
and this is de output:
As you can see, the first and third
<p>
are fine. But the rest aren`t. The second is the matched value of {form 2} but didn't enter in the replace function. The forth is only part of the matched value of {form 1:3} and also didn't enter in the function. And the last did enters in the replace function but the match is "";