Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RinNguyens opened this issue Oct 3, 2022 · 1 comment
Open

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

RinNguyens opened this issue Oct 3, 2022 · 1 comment

Comments

@RinNguyens
Copy link

RinNguyens commented Oct 3, 2022

code-problem

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

@tchajed
Copy link

tchajed commented Jun 14, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants