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

the negtive lookahead and negtive lookbehind seems not supported. #211

Closed
JohnHerry opened this issue Feb 20, 2023 · 2 comments
Closed

the negtive lookahead and negtive lookbehind seems not supported. #211

JohnHerry opened this issue Feb 20, 2023 · 2 comments

Comments

@JohnHerry
Copy link

JohnHerry commented Feb 20, 2023

Thanks for the good job.
I am a pythoner trying to convert my python program into C++, I found that my regulare strings with negtive lookahead or negtive lookbehind will match just like the "negtive lookahead" and "negtive lookbehind" part are not exist.

eg.
my regure string is “(?<![a-zA-Z0-9])(H2O|Covid-19|Windows)(?![a-zA-Z0-9])”

In my expection, it will match when input string is "My Computer runs Windows 12", but not "this is Windows10" or "AWindows is my program".

But, in my test, all the three are matched out the keyword "Windows", I donot know why. Is there any compile options in PCRE2 to open/close lookahead/lookbehind?

@ltrzesniewski
Copy link
Contributor

In my expection, it will match when input string is "My Computer runs Windows 12", but not "this is Windows10" or "AWindows is my program".

Your expectation is correct, see the test here: https://regex101.com/r/34P16P/1

But, in my test, all the three are matched out the keyword "Windows", I donot know why. Is there any compile options in PCRE2 to open/close lookahead/lookbehind?

There's no option to disable lookarounds. I suppose you must have made a mistake in your program somewhere.

@JohnHerry
Copy link
Author

In my expection, it will match when input string is "My Computer runs Windows 12", but not "this is Windows10" or "AWindows is my program".

Your expectation is correct, see the test here: https://regex101.com/r/34P16P/1

But, in my test, all the three are matched out the keyword "Windows", I donot know why. Is there any compile options in PCRE2 to open/close lookahead/lookbehind?

There's no option to disable lookarounds. I suppose you must have made a mistake in your program somewhere.

Thanks for the help. I will check it.

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