News for hackers. Stuff that matters.
Re:Regular Expression That Checks If A Number Is Prime by db48x on Thursday September 08, 2016 @09:32PM (#12459062)
"regular language" is a mathematical term. You can add any features you want to your matcher, but some features allow you to match languages that are not "regular".

However, most programmers are not mathematicians or computer scientists, and so are effectively using lay terminology which is similar to but not precisely the same as the mathematical terminology. Most programmers only care that their regex library allows them to concisely match strings, not that it allows them to match regular languages.

Thus there are two standards you could follow: the precise mathematical definition of "regular", or the lay definition.

Re:Regular Expression That Checks If A Number Is Prime by greydius on Thursday September 08, 2016 @10:56PM (#12459370)
I don't buy the layman argument. Programmers might not be mathematicians or computer scientists, but they should be professionals and held to the same standards as professionals in other fields. For example, a mechanical engineer doesn't use a "laymen" definition of tensile strength when choosing materials for a design.
Re:Regular Expression That Checks If A Number Is Prime by eponeponepon on Friday September 09, 2016 @12:57AM (#12459717)
No, but he probably does use layman's terms when describing molecular lattices and electron shells. If he ever does.

The point here is that users of (colloquial) regular expressions, however professional they are or aren't, are just engaging with the surface of a deeper set of mathematical principles that require greater nuances of meaning to discuss than their applications do.

Re:Regular Expression That Checks If A Number Is Prime by OskarS on Friday September 09, 2016 @10:39AM (#12462637)
I basically agree, but I would say that a slightly deeper understanding of regular expressions is a really useful thing to know for basically all professional programmers. If for no other reason they can recognize the "pathological" cases where backtracking implementations (i.e. almost all modern regex implementations) would need until the heat death of the universe to evaluate.
Re:Regular Expression That Checks If A Number Is Prime by chongli on Friday September 09, 2016 @07:41AM (#12461224)
Programmers might not be mathematicians or computer scientists, but they should be professionals

What? No. Many programmers out there are just working on fun projects in their spare time. I'm sure there exist some aerospace engineers doing that, but it's not many. I don't see why your average bedroom open source programmer should be treated like an aerospace engineer.

Re:Regular Expression That Checks If A Number Is Prime by db48x on Friday September 09, 2016 @12:43AM (#12459679)
Programmers have more freedom from the constraints of reality than mechanical or civil engineers.
Re:Regular Expression That Checks If A Number Is Prime by UlyssesSKrunk on Friday September 09, 2016 @10:39AM (#12462633)
What the fuck are you talking about? Those aren't even remotely the same thing at all.
Re:Regular Expression That Checks If A Number Is Prime by Chinjut on Thursday September 08, 2016 @09:40PM (#12459094)
Right. My point (which may not be a particularly great point, but it was what I was trying to convey) is that the lay definition doesn't have any particular tight borders; presumably different regex libraries are capable of matching different things, use different syntax, etc.

(And this is part of why I find it confusing terminology and would prefer "regular expression" only to mean specifications of regular languages in the original formal sense. But, of course, I'm not the king of language, and it's natural that people would speak the way they speak, given the circumstances.)

Re:Regular Expression That Checks If A Number Is Prime by Retra on Thursday September 08, 2016 @10:21PM (#12459265)
The lay definition isn't a definition, per se, it's a misappropriate of the term. Since the lay user only cares about text matching, the term for what they need is "text matching syntax" or some such thing.

And surely you don't think those implementing the regular expression engine are lay people. They should know better.

Re:Regular Expression That Checks If A Number Is Prime by thaumasiotes on Friday September 09, 2016 @04:31AM (#12460451)
> there are two standards you could follow: the precise mathematical definition of "regular", or the lay definition

Considering this writeup leads with a giant headline saying "Regular Expressions - The Theory"... I think the complaints about how it's not actually a regular expression are even more valid than usual.