dlclark / regexp2

A full-featured regex engine in pure Go based on the .NET engine
MIT License
987 stars 83 forks source link

Add support for Perl(PCRE) named and unnamed group capturing order #43

Open CIAvash opened 3 years ago

CIAvash commented 3 years ago

In other words maintain the order of capture groups. With the MaintainCaptureOrder regexp option.

I also added inline option o. It's useful if you only have access to the pattern, but not the regex. But it only is useful if used at the start of the pattern, I couldn't find a way to prevent it from being used elsewhere.

I've never liked nor have been good with bitwise operations. So I don't know if I should've picked another number.

dlclark commented 3 years ago

Thanks for submitting this! It'll take me a bit to review and gather my thoughts on it.

yywing commented 3 years ago

Is there anyway get named group?

like (1)(?<aa>2)

I want get aa only.

CIAvash commented 3 years ago

@yywing Don't know why you asked that question here, as it's not relevant to the pull request. But you can do match.GroupByName(`aa`).