Earlier quoted context omitted.
One of my pet peeves is how PRCE destroyed the definition of "regular" in regular expressions. It has basically made a huge number of programmers illiterate as to what truly is regular in the formal sense.
But why should people care about what is regular in the formal sense ? Rather, regular in this context would mean it can be recognized with a restricted type of algorithm, which resembles the formalism.
Regular Expression That Checks If A Number Is Prime
51–60 of 117 posts
Re: Regular Expression That Checks If A Number Is Prime
#52Earlier quoted context omitted.
Sure, for a fixed arbitrary integer M. (Supposing the input is fed in in big-endian order, you just keep track of the remainder modulo M as each new bit comes in, updating it by turning r into (r * 2 + new bit) mod M. Since this only requires finite state, it is regular). But that won't get you a primality checker. You can't get a primality checker. Primes don't comprise a regular language, neither in unary nor in an…
What do you mean by "non trivial base?"
Re: Regular Expression That Checks If A Number Is Prime
#53Earlier quoted context omitted.
Is there a standard for which additional features one can add on top of regular expressions in the original limited sense and still be considered a regex?
"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 allow…
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
#54Earlier quoted context omitted.
One of my pet peeves is how PRCE destroyed the definition of "regular" in regular expressions. It has basically made a huge number of programmers illiterate as to what truly is regular in the formal sense.
But why should people care about what is regular in the formal sense ? Rather, regular in this context would mean it can be recognized with a restricted type of algorithm, which resembles the formalism.
Re: Regular Expression That Checks If A Number Is Prime
#55Earlier quoted context omitted.
Is there a standard for which additional features one can add on top of regular expressions in the original limited sense and still be considered a regex?
"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 allow…
Re: Regular Expression That Checks If A Number Is Prime
#56It should be noted that this is not possible with regular expressions in the traditional sense (i.e. regular expressions only matching regular languages): http://math.stackexchange.com/a/181233/21405 Because of back references PCRE regular expressions can match non-regular languages as well.
"Thus the question arises: Can regular expressions match only regular grammars, or can they also match more? The answer to this is both yes and no"...
Re: Regular Expression That Checks If A Number Is Prime
#57Re: Regular Expression That Checks If A Number Is Prime
#58It should be noted that this is not possible with regular expressions in the traditional sense (i.e. regular expressions only matching regular languages): http://math.stackexchange.com/a/181233/21405 Because of back references PCRE regular expressions can match non-regular languages as well.
One of my pet peeves is how PRCE destroyed the definition of "regular" in regular expressions. It has basically made a huge number of programmers illiterate as to what truly is regular in the formal sense.