-
Notifications
You must be signed in to change notification settings - Fork 58
feat(String): RegExp S.Replace, S.Match and S.MatchAll
#89
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
feat(String): RegExp S.Replace, S.Match and S.MatchAll
#89
Conversation
S.replace and S.matchS.Replace, S.Match and S.MatchAll
|
@didavid61202 I tried this with a couple of use cases and this is great. I could find any bug with the regexp features I've tried so far, amazing job! Something that worries me a little is the fact that your package has a global declaration altering string methods. I don't want hotscript to mess with global declarations to avoid unexpected side effects of installing this lib in an existing project. Do you think you could extract the pure type-level code in a different package? |
|
Oh oh, merged by mistake. |
Thanks @gvergnaud 😊 Do let me know if you find any bugs 👍 I think that we do not have a global declaration side effect. I have made a subpath export ( |
|
@ecyrbe I'm going to override the main branch to unmerge |
|
Done. @didavid61202 Do you mind re-opening a PR? |
Done, re-open at #94 🎊 Thanks |
Updates
S.Replaceto also accept RegExp pattern (/<pattern>/) asfromarg to replace substring matched by the given pattern. Replace value also support special replacemnet patterns.S.Matchto match a string against a RegExp (supportiandgflags), returns a matched object with match array andindexandgroupsproperties.S.MatchAllto match a string against a RegExp, return an array of match objects, each with a match array andindexandgroupsproperties.S.Replace,S.MatchandS.MatchAllall returnsRegExpSyntaxErrorerror type with detail error message when the provided RegExp contain Syntax error (currently only show few types of error, WIP)Note
I have kept the implementation of RegExp matching and replacing generic types in a separate package called type-level-regexp. This allows for faster iteration as it is still in the early stages, and more features and performance improvements are coming along the way.
Usage
Related issues
Resolve #33
Tasks