in reply to Re: regex gotcha moving from 5.8.8 to 5.30.0?
in thread regex gotcha moving from 5.8.8 to 5.30.0?
All of your regexps match up to (but not including) the newline. Based on the comment that '^' might be causing problems, I just added a '\s*' to the end of each regexp so basically each one of them grabs the newline and any additional whitespace. The following runs quickly for all versions:
sub parse_foo { my ($text) = @_; my $name; { last if $text =~ /\G \Z/gcmsx; if ($text =~ /\G begfoo \s+ (\S+?) \s* \( \s* (.*?) \s* \) + \s* ; \s*/gcmsx) { $name = $1 } elsif ($text =~ /\G endfoo \s* /gcmsx) { } elsif ($text =~ /\G \S+ \s+ .*? \s* ; \s*/gcmsx) { } else { die "ERROR: unknown syntax\n" } redo; } print "LAST FOO: $name\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: regex gotcha moving from 5.8.8 to 5.30.0?
by mordibity (Acolyte) on Feb 11, 2021 at 21:09 UTC | |
by tybalt89 (Monsignor) on Feb 12, 2021 at 02:56 UTC | |
by rsFalse (Chaplain) on Feb 11, 2021 at 22:40 UTC |