-
Notifications
You must be signed in to change notification settings - Fork 55
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
Consider supporting the full String.prototype.replace API #6
Comments
Relates to #8 |
@iansinnott, I think, in order to have the API as below, the index would need to go and would introduce a breaking change to current react-string-replace API. I assume the index is only needed for function replacer(match, p1, p2, p3, offset, string) {
// p1 is nondigits, p2 digits, and p3 non-alphanumerics
return [p1, p2, p3].join(' - ');
}
var newString = 'abc12345#$*%'.replace(/([^\d]*)(\d*)([^\w]*)/, replacer); |
Yeah, looking at the docs the string replace API seems a bit odd. I initially want with Since offset is unique it does seem that we could make due without index. I like the idea of supporting the standard API but I also don't have a need for it. Open to discussion |
@iansinnott, I think I grok it now. And I actually found a use-case in my application. The use case is basically this:
Now, I can provide a grouped regex for matching the two character groups eg: |
Let me give you a pull request. |
@iansinnott I did not modify the server <> client example, since I do not understand how you deploy this on local... I suppose the code needs bundling first. There is no script in the |
I have added a bit more information to readme, but I think I am making it a bit cluttered with former examples. |
Having support for this would be really great. I'm currently trying to transform |
Not sure how big a lift this would be, but something to think about.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
The text was updated successfully, but these errors were encountered: