iansinnott / react-string-replace

A simple way to safely do string replacement with React components
MIT License
652 stars 56 forks source link

reactStringReplace is returning a blank string for match #7

Closed JacobTheEvans closed 8 years ago

JacobTheEvans commented 8 years ago

I am having an issue below that when I run the code below a match is found but an empty string is returned for the match.

//code

let newStr = reactStringReplace(str, /\[img.*?]/g, (match, i) => (
  <img key={"processed: " + match + i} src={match.replace('[img src="', " ").replace('"]', "")} />
));

//input

[img src="http://i.imgur.com/GBpbHPh.png"]

Any advice?

iansinnott commented 8 years ago

Hm, that's odd. Definitely sounds like a bug. I'd love to add a test for this to keep it from happening again. I'm not sure off hand what the issue might be but I'm happy to help out. Could you create a repo where I can reproduce this?

JacobTheEvans commented 8 years ago

After more experimenting, I realized it was an issue with my regex pattern. So I will close this issues sorry about that.