6 ms·
I find it highly annoying that this, as far as I understand, really doesn't use regular expressions. The s/that/this/ syntax is not, of course, a regular expre
by unwind 16y ago
I find it highly annoying that this, as far as I understand, really doesn't use regular expressions.
The s/that/this/ syntax is not, of course, a regular expression. The regular expression is the thing that might go into the "that" part, an expression that can match against several different inputs. If all it supports is literals, it's not really worth calling it a regular expression, in my opinion.
The article expresses this like so:
Some experimentation shows that it isn't a full regular expression engine, it will only do straight word substitution.
I think this is stretching it; sure all literal strings are regular expressions, but if that's all there is (i.e. no alteration, repeat etc), then why call it an RE at all?
Am I just being grumpy?
- djacobs 16y agoI agree with you. This is simple substitution. (If we're going to call this a regex mechanism, so is Find/Replace in Word.)
- nicpottier 16y agoOh, no argument there, though being "highly annoyed" may point to some grumpiness. It is clearly not a regex engine, but it operates like a very very naive one, and uses the Perl syntax for them. Ultimately Regex just seemed like the easiest / clearest way of describing the functionality. IE, if I say "Skype supports the Perl Regex syntax for simple word substitution" you probably instantly think of s/a/b/. Maybe I should have used that as the headline, but it seemed a bit long.
- zeugma 16y agoHistoricaly it is more a sed like syntax..
- Dylan16807 16y agoAnd 'sed' is even easier to say than 'perl regex'!
- j_baker 16y agoI probably would have said "It supports sed-like substitution" (or maybe even s/sed-like/vim-like/). Generally speaking, regular expressions denotes finding something while this does more than that. Regardless, this level of pedantry shouldn't come as a surprise on HN (I admit to being guilty of it myself).
- jgrahamc 16y agoI agree. Annoyed me also. There's nothing regexp about it at all. And then TFA says that this is 'Perl syntax'. Sure, Perl uses that syntax but it was inherited from sed which got it from ed.
- nicpottier 16y agoMan, everybody is grumpy today, happy valentines? :) I know Perl. It is the Perl syntax for regular expressions. I never said it was the first or only to use that syntax. Sheesh.
- jgrahamc 16y agoOK. I'll cheer up. Here's my Valentine's Day appropriate story. http://blog.jgc.org/2011/02/hacking-toshiba-t4800ct-love-story_9458.html http://blog.jgc.org/2011/02/hacking-toshiba-t4800ct-love-sto...
- baddox 16y agoI think that's a bit grumpy. It's fair to call this "regex," not because it's exactly a regular expression matcher, but because it clearly borrows its syntax from a popular regular expression engine (one that's traditionally used for simple word replace in chat windows). Similarly, most people use the term "regex" to refer to the full engines in most programming languages, which are often much more powerful than actual regular expression matchers (e.g. back references).