Skip to content
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

Can regexp2 provide the same APIs adapt to std.regexp? #42

Open
vipally opened this issue Mar 17, 2021 · 5 comments
Open

Can regexp2 provide the same APIs adapt to std.regexp? #42

vipally opened this issue Mar 17, 2021 · 5 comments

Comments

@vipally
Copy link

vipally commented Mar 17, 2021

I wander if regexp2 can provide the same APIs adapt to std.regexp.
So that I can change my rely between regexp2 & std.regexp easily by just change the expr text only.

@vipally vipally changed the title if regexp2 can provide the same API as gostd.regexp Can regexp2 provide the same API as gostd.regexp? Mar 17, 2021
@vipally vipally changed the title Can regexp2 provide the same API as gostd.regexp? Can regexp2 provide the same API compare with gostd.regexp? Mar 17, 2021
@vipally vipally changed the title Can regexp2 provide the same API compare with gostd.regexp? Can regexp2 provide the same APIs compare with gostd.regexp? Mar 17, 2021
@dlclark
Copy link
Owner

dlclark commented Mar 17, 2021

I’m assuming gostd.regexp is the go standard library regexp package.

This package isn’t designed to be a drop-in replacement for the standard library.

At first blush a conversation layer doesn’t seem too difficult so it seems like a project that requires swapping between them could write a normalization layer.

Have you tried writing this layer yourself and run into problems? Are there specific functions or concepts from regexp you want that aren’t present in regexp2?

@vipally
Copy link
Author

vipally commented Mar 17, 2021

https://gitee.com/gxlb/gogp/blob/dev_gt/syntax.go#L52
I am doing some heavy regexp processing, what need back-reference syntax from regexp library, which is not supported by std.regexp.
I found regexp2 meet all what I need.

I have try to export this APIs at https://gitee.com/gxlb/gogp/blob/dev_gt/vendor/github.com/dlclark/regexp2/regexp_api.go
But failed today, I'll try latter.
It will be greatfull if regexp2 directly adapt all APIs from std.regexp library.

@vipally vipally changed the title Can regexp2 provide the same APIs compare with gostd.regexp? Can regexp2 provide the same APIs compare with std.regexp? Mar 17, 2021
@vipally vipally changed the title Can regexp2 provide the same APIs compare with std.regexp? Can regexp2 provide the same APIs adapt to std.regexp? Mar 17, 2021
@vipally
Copy link
Author

vipally commented Mar 17, 2021

https://gitee.com/gxlb/gogp/blob/dev_gt/vendor/github.com/dlclark/regexp2/std_regexp_api.go
I have sucessfully replaced std.regexp with regexp2.
When I finish adapt other unused APIs, may I put a PR to regexp2 to compatibility with std.regexp APIs?

@dlclark
Copy link
Owner

dlclark commented Mar 17, 2021

Sure! Be sure to document the compatibility goal in the README and include tests.

@vipally
Copy link
Author

vipally commented Mar 18, 2021

Here is something that I want to do on regexp2 next:

  1. Add compatibility with std.regexp APIs
  2. Add coverage test cases
  3. Add examples of APIs usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants