in reply to Regex matching on anywhere but the beginning or end of a line
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regex matching on anywhere but the beginning or end of a line
by BrowserUk (Patriarch) on Feb 23, 2003 at 13:07 UTC | |
by xmath (Hermit) on Feb 23, 2003 at 13:17 UTC | |
|
Re: Regex matching on anywhere but the beginning or end of a line
by Abigail-II (Bishop) on Feb 23, 2003 at 01:56 UTC | |
by xmath (Hermit) on Feb 23, 2003 at 09:53 UTC | |
by Dr.dos (Initiate) on Feb 25, 2003 at 01:49 UTC | |
by Abigail-II (Bishop) on Feb 25, 2003 at 08:19 UTC |