Closed didavid61202 closed 1 year ago
@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.
@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?
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 (type-level-regexp/regexp
instead of type-level-regexp
) specifically for types, and importing from this subpath should not import the file that contain the global declaration. During my testing, I have not observed any side effects so far. However, I may have missed something that I am not aware of.
@ecyrbe I'm going to override the main branch to unmerge
Done. @didavid61202 Do you mind re-opening a PR?
Done. @didavid61202 Do you mind re-opening a PR?
Done, re-open at #94 π by the way, @gvergnaud do I still need to extract the pure type-level code in a different package for avoiding global declaration side effect? or subpath export of current setup is ok?
Thanks
Updates
S.Replace
to also accept RegExp pattern (/<pattern>/
) asfrom
arg to replace substring matched by the given pattern. Replace value also support special replacemnet patterns.S.Match
to match a string against a RegExp (supporti
andg
flags), returns a matched object with match array andindex
andgroups
properties.S.MatchAll
to match a string against a RegExp, return an array of match objects, each with a match array andindex
andgroups
properties.S.Replace
,S.Match
andS.MatchAll
all returnsRegExpSyntaxError
error 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