compile-time-regular-expressions icon indicating copy to clipboard operation
compile-time-regular-expressions copied to clipboard

Possessive qualifier "?+" is not supported.

Open heyingge-1560733 opened this issue 2 years ago • 7 comments

  1. Possessive qualifier "?+" is not supported. ~2. ctre::range matches an empty string will cause infinite loop, e.g., for (auto&& m : ctre::range<"a|(ab)?">("aab"));~ (moved to issue #222)

heyingge-1560733 avatar Sep 12 '21 04:09 heyingge-1560733

Isn't the first one supposed to be +??

BenBE avatar Sep 12 '21 07:09 BenBE

Why?

heyingge-1560733 avatar Sep 12 '21 09:09 heyingge-1560733

They're different things. +? is + but nongreedy (match as few times as possible while still making the overall regex match); ?+ is ? but possessive (match as many times as possible, and never backtrack; if backtracking would be needed, backtrack somewhere earlier in the regex, or just fail).

Alcaro avatar Sep 12 '21 09:09 Alcaro

Splitting this issue into two: https://github.com/hanickadot/compile-time-regular-expressions/issues/222

hanickadot avatar Sep 12 '21 09:09 hanickadot

Sorry, I don't get it. I am saying that ?+ is not supported and it is a possessive qualifier, isn't it? CTRE returns syntax error while compiling, e.g., ?+.

heyingge-1560733 avatar Sep 12 '21 09:09 heyingge-1560733

@heyingge-1560733 the possessive optional added in 2e8aaf2aa09a651a05144da61b7e6c7606dd247c, I originally didn't implement it because I didn't see any usecase for it. But after recent unification of cycles and optionals it makes sense to have it.

hanickadot avatar Sep 12 '21 09:09 hanickadot

@hanickadot I will try later. Thanks!

heyingge-1560733 avatar Sep 12 '21 10:09 heyingge-1560733