react-string-replace icon indicating copy to clipboard operation
react-string-replace copied to clipboard

I have a problem with '/r' in text. It not working '/r'

Open RinNguyens opened this issue 2 years ago • 1 comments

code-problem

result : reactStringReplace output not working '/r' in array[2] image above results

RinNguyens avatar Oct 03 '22 04:10 RinNguyens

My guess (because I had the same bug) is that you need to use a capturing group in your regex:

  let el = reactStringReplace(el, /(\n)/g, (_match, i) => <br key={i} />);

Note the use of /(\n)/g rather than just /\n/g.

tchajed avatar Jun 14 '23 16:06 tchajed