News for hackers. Stuff that matters.
Re:Exploring the Linguistics Behind Regular Expressions by steffann on Sunday March 04, 2018 @05:23AM (#16514105)
I get the suspicion that the writer doesn't understand the ?, * and + operators...
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).

Re:Exploring the Linguistics Behind Regular Expressions by posterboy on Sunday March 04, 2018 @06:39AM (#16514345)
a correction would be helpful.

   /x?/ one or none x
   /x+/ one or more x
   /x*/ none or more x
with variable operators it's more complicated. In /.+/ the operator is repeated, not the first match as with /(.)\1*/

Also, there are extensions in various implementations that are not in fact a regular, so no finite automata.