This however seems to be slower, according to a quick benchmark I've run (zwa = 'zero-width assertion', sub = 'substr'):substr($t, 1, -1) =~ s/"/""/g;
But it is perhaps easier to understand (which would make it a better choice if the speed difference isn't relevant)Benchmark: timing 1048576 iterations of sub, zwa... sub: 16 wallclock secs (15.07 usr + 0.00 sys = 15.07 CPU) @ 69 +580.36/s zwa: 13 wallclock secs (12.58 usr + 0.00 sys = 12.58 CPU) @ 83 +352.62/s Rate sub zwa sub 69580/s -- -17% zwa 83353/s 20% --
•Update: ran the benchmark again, this time without other processes eating up wallclock secs; to avoid confusion
•Update: I'm enclosing my (fairly pointless) benchmark stuff in readmore-tags to avoid cluttering the thread
In reply to Re: Regex matching on anywhere but the beginning or end of a line
by xmath
in thread Regex matching on anywhere but the beginning or end of a line
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |