iansinnott / react-string-replace

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

Add character start index to function arguments #8

Closed pejrak closed 7 years ago

pejrak commented 7 years ago

Hi, I your package helped me in a project where I wanted to wrap fields in a text. Fields were used to replace the matched strings with something else. However, I was missing the information about index of the match start character within the text. I will reference my solution.

iansinnott commented 7 years ago

Cool, thanks @pejrak. This is a good reference for anyone trying to do the same. I'm going to close this out but if there's additional action you'd like to take feel free to reopen.

pejrak commented 7 years ago

Alright, this is probably isolated to my case/scenario. Please consider reviewing/adding if there is anyone else needing that. Thanks for the package and reply.

iansinnott commented 7 years ago

Did you want to incorporate this into the library? I didn't know because this is an Issue instead of a Pull Request.

Looking at the official String.prototype.replace docs it does seem that the official function is called with addition args. I would certainly be in support of mirroring that API since it's consistent with JS.

Maybe you could make a PR with your changes and we can discuss there?

pejrak commented 7 years ago

Ian, I had other commitments last week, but I just added a pull request to my fork.

Let me see if I can write a test on this.

pejrak commented 7 years ago

I suppose this is the offset from String.prototype.replace docs

Test added.

iansinnott commented 7 years ago

Published in v0.4. Thanks for the help on this one @pejrak