Hacker News new | ask | show | jobs
by yorwba 3035 days ago
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).