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

[Question] How to match a string at start and end of token without capturing groups #170

Open
inferrinizzard opened this issue Jan 20, 2022 · 1 comment

Comments

@inferrinizzard
Copy link

inferrinizzard commented Jan 20, 2022

I am converting my custom tokenizer to moo and ran into a problem case:

// a pattern that used to look like this:
'(?<tag>\\$\\w*\\$)[\\s\\S]*?(?:\\k<tag>|$)'
// as regex literal:
/(?<tag>\$\w*\$)[\s\S]*?(?:\k<tag>|$)/

This pattern tries to match Postgres $$ strings, such as:

-- standard && string
$$lorem ipsum dolor$$
-- custom $$ string with tag (fails here)
$example$this example string fails$example$

The pattern normally works by backreferencing the captured tag between the first dollar signs to check if the second pair of dollar signs has the same tag but this breaks without the use of capturing group when lexing with moo.

Any suggestions on how to workaround this limitation ?

@inferrinizzard
Copy link
Author

I see #132 , same issue here

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

1 participant