firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.24k stars 199 forks source link

global search flag doesn't exist in PCRE #1966

Closed yaronelh closed 1 year ago

yaronelh commented 1 year ago

Bug Description

global search flag doesn't exist in PCRE / PCRE2

Reproduction steps

the interface lets you turn off the g flag while PCRE / PCRE2 are selected but those engines do not support the g flag, rather those engines will match every occurrence in the string and there's no way to change it with the flag. more accurately their only state is g as a selected state in the drop down, with no flag to change that behavior.

Expected Outcome

the selection in the dropdown should be set to the default of these engines (selected) without the ability to change.

Browser

Include browser name and version

OS

Include OS name and version

working-name commented 1 year ago

Hello there,

From what I understand PCRE is a library, whereas PHP that's in parenthesis is a language that implements said library in a specific way. To continue with the PHP example, it cannot do the /g flag, but instead it provides preg_match_all() which is the same thing.

Perl also implements the /g flag, and PCRE stands for perl-compatible...

The flag selection dropdown is self-limiting/correcting in the sense that it will remove flags that are already selected if the newly selected flavor does not support them. Prior to doing that, it'll "translate" the flag to its relative counterpart (PCRE /A -> JS /y) if one such flag exists.

The default flags are /gm, but preventing the user from changing these flags no matter the engine is likely a step backwards in usability.

yaronelh commented 1 year ago

just noticed that the implementation is specific for PHP, Sorry about that. 👍 not every implementation of the library allows for that, as far as I can see the library itself doesn't include it.

that is where I was looking https://www.pcre.org/pcre2.txt

Cheers