in reply to Re: japhy blabs about regexes (again)
in thread japhy blabs about regexes (again)
That regex is worse. You'd think by breaking \s+ down into \s*\s, you'd get the best of both worlds -- the "1 or more" meaning, and the "trailing character" optimization. No such luck. In fact, the regex does MORE work, because of backtracking. :(
You see, Perl doesn't even see if the string has ANY trailing whitespace if you do /\s+$/. Meaning it takes a while to fail for a string like "a b c d e f g h i j k l m n o p q r s t u v w x y z". How sad.
The output (if you understand it) will upset you. Well, it upset me.# try this, and be sad :( use re 'debug'; "abc def ghi" =~ /\s+$/; "abc def ghi" =~ /\s*\s$/;
_____________________________________________________
Jeff japhy Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|