in reply to RE question...yup, another one ;)
There are four generic approaches to this:
If snafu doesn't mind, I'd like to use this as an example in my book -- first to show how to craft a regex, then to show why there are some places where a regex is overkill.use Benchmark 'timethese'; $x = int (1_000_000 * rand 1_000_000); timethese(-5, { multiple => sub { $x =~ /(\d)*(\d)/ }, backtrack_c => sub { $x =~ /(\d*)(\d)/ }, backtrack => sub { $x =~ /\d*(\d)/ }, opt => sub { $x =~ /(\d)$/ }, mod => sub { $x % 10 }, });
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: japhy regex analysis: case study (RE question...)
by tye (Sage) on May 28, 2001 at 02:42 UTC | |
by japhy (Canon) on May 28, 2001 at 05:22 UTC | |
by tye (Sage) on May 28, 2001 at 07:53 UTC | |
by snafu (Chaplain) on May 30, 2001 at 01:56 UTC | |
by japhy (Canon) on May 28, 2001 at 03:39 UTC | |
|
Re: japhy regex analysis: case study (RE question...)
by snafu (Chaplain) on May 30, 2001 at 01:42 UTC |