in reply to Re: japhy blabs about regexes (again)
in thread japhy blabs about regexes (again)
Except that mine is faster, since it's written in C. The results vary greatly. It comes down to knowing your string. If your string has lots of chunks of whitespace, the regular regex approach is bad. If your string has a long string of trailing whitespace, the rnchrpos() approach is bad. If there's no trailing whitespace, or very little, the while approach and the rnchrpos() are good. The sexeger approach is pretty good if the string isn't very long. If your string has a few chunks of whitespace the regular regex approach is good.sub rnchrpos { my ($str, $chars, $pos) = @_; $pos ||= $pos; $pos += length $str if $pos < 0; return ( substr($str, 0, $pos) =~ /[\Q$chars\E]*\z/ ? $-[0] - 1 : -1 ); }
We live in a very variable world.
_____________________________________________________
Jeff japhy Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
---|