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

strange behaviour in matching (bug?) #84

Closed
ChristianS99 opened this issue Feb 4, 2022 · 2 comments
Closed

strange behaviour in matching (bug?) #84

ChristianS99 opened this issue Feb 4, 2022 · 2 comments

Comments

@ChristianS99
Copy link

ChristianS99 commented Feb 4, 2022

echo -n 'rr' |rg -P '[Rr]{2}' -q; echo $?
1
echo -n 'rr' |rg -P '[rR]{2}' -q; echo $?
0
echo -n 'rr' |grep -P '[Rr]{2}' -q; echo $?
0
echo -n 'rr' |grep -P '[rR]{2}' -q; echo $?
0

rg is https://github.com/BurntSushi/ripgrep
ripgrep is using libpcre2, grep is using libpcre

same is visible in php7.4 and php8.1:

php > echo preg_match('/[rR]{2}/', 'rr');
1
php > echo preg_match('/[Rr]{2}/', 'rr');
0

that version also use libpcre2, php <=7.2 should use libpcre, but I don't have it available to test,
but you can try it on regex101.com and switch the flavours.

https://regex101.com/r/8Sfund/1
it has pcre2 preselected, that doesn't match and pcre matches, including all other flavours available there.

I'm no regex expert, let alone know about subtle differences between flavours, but for me it doesn't make sense, that the order of characters in [] matters, so I think it is a bug.
If not, please enlighten me, why this is, as it should be.

@PhilipHazel
Copy link
Collaborator

Thanks for the report, but this bug was recently reported and has already been fixed:

commit fdd9479
Author: Philip Hazel Philip.Hazel@gmail.com
Date: Wed Jan 26 08:37:18 2022 +0000

Fix incorrect compiling when [Aa] etc. are quantified

@ChristianS99
Copy link
Author

ok, sorry, only checked open issues, not closed ones

Fix is working for me, thx

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