4 ms·
This reduction is really cool. I love reductions like this. Is there a general consensus to use "regular expression" to refer to the actual regular ones and "r
by awirth 6y ago
This reduction is really cool. I love reductions like this.
Is there a general consensus to use "regular expression" to refer to the actual regular ones and "regex" to refer to the non-regular variants?
- praptak 6y agoI don't think so. Usually you can tell from the context: # math and/or computer science texts? It's the regular ones. # pretty much elsewhere? It's the extended ones. # threads about parsing HTML with regular expressions? People using both and insisting their version is the only correct one.
- zokier 6y agoI think Raku (neé Perl 6) has been spearheading that distinction https://docs.raku.org/language/regexes https://docs.raku.org/language/regexes (see the intro paragraph)
- chubot 6y agoI wouldn't say so, but I use the term "regular language" if I mean the mathematical concept.
- robinhouston 6y agoI don’t think it’s pedantic to say that a regular language is not the same thing as a regular expression. The difference between syntax and semantics is real and important.
- chubot 6y ago(late reply) Right that's what I'm saying. Who said it was pedantic? :)
- gnulinux 6y agoBut a "regular language" is not the same as "regular expression" as mathematical concepts.
- chubot 6y ago(late reply) Hm you've negelected to do the obvious thing and explain the difference. I don't think there's a difference, and if there is one, it's probably not relevant to programming. Whereas the one I'm highlighting is relevant to programming.
- robinhouston 6y agoThis distinction was introduced by Jeffrey Friedl’s book _Mastering Regular Expressions_ (2006), and it seems to be fairly commonly used now.
- stevefan1999 6y agoIsn't it PCRE that we started to call it regex?
- gbacon 6y agoYes, for at least ten years and likely much longer. https://cstheory.stackexchange.com/q/448/362 https://cstheory.stackexchange.com/q/448/362
- awirth 6y agoInteresting, I wasn't aware of the history. Personally I make the distinction, but I've noticed many many people do not, hence the question.
- gbacon 6y agoPeople without theoretical CS background probably think of regular expressions (or regexes for short) as just text-matching thingies that sometimes give you two problems and would look at you blankly if you mention the Chomsky hierarchy. When we don’t know there’s a distinction to be made, we go for economy of expression.
- awirth 6y agoToo late to edit, but out of curiosity I re-implemented this to use the PCRE JIT (in PHP) to see what kind of speedup it would provide: https://gist.github.com/allanlw/69df509519335b88db886d48503a0f15 https://gist.github.com/allanlw/69df509519335b88db886d48503a... Timings for fred.cnf on my machine: python: 0m53.744s PHP (no PCRE JIT): (hits backtrack limit in 1m15.994s) PHP (PCRE JIT): 0m20.109s