News for hackers. Stuff that matters.
Re:Exploring the Linguistics Behind Regular Expressions by yorwba on Sunday March 04, 2018 @06:20AM (#16514293)
There is a problem here in that different regex libraries have different semantics for these.

I checked the manual for PCRE (man pcrepattern), and it says that ? has both the meaning of {0,1} (zero or one repetition), as well as turning * and + into non-greedy variants if directly following them.

Similarly, + usually has the meaning of {1,} (at least once) but can also quantify * and + to prevent backtracking.

For an engine whose semantics differ from PCRE, non-greedy matching or backtracking might not even make sense, if the matching is implemented differently (e.g. using finite automata that don't backtrack).

There are no comments on this comment yet.