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

Capturing groups #229

Closed
tomsonpl opened this issue Jul 13, 2020 · 2 comments
Closed

Capturing groups #229

tomsonpl opened this issue Jul 13, 2020 · 2 comments
Labels

Comments

@tomsonpl
Copy link

Hi, first of all big thanks for your work ;)
I am using your library to parse my kind of complicated friendly URL.

Do you think it is / would be possible to have a regexp like this? I mean including captured groups.

const priceRegex = "(cena)?(-od-:price_0(\\d+))?(-do-:price_1(\\d+))?(-zl)?";

I am trying to work around it, however this would be very useful in the future.

Thanks in advance,

@mastermatt
Copy link

There is a recent PR to add named capture groups here #225

@blakeembrey
Copy link
Member

blakeembrey commented Aug 10, 2020

I believe this is basically already supported if you replace the outer () with {}, e.g. {-od-:price_0(\\d+)}?. It allows for a custom prefix and suffix.

There's not a lot of documentation right now, but your example is similar to the one the in README here: https://github.com/pillarjs/path-to-regexp#custom-prefix-and-suffix.

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

No branches or pull requests

3 participants