loikiolki has asked for the wisdom of the Perl Monks concerning the following question:
I've got this regex that I'm trying to make work. Maybe I don't properly understand how negative look-behinds function. From what I understand in the docs, the following code (w/ regex):
$file = '_error' unless ($file =~ /\A(?<!compiled)a-zA-Z0-9]+\z/);should do the same thing as this:
$file = '_error' if ( substr($file, 0, 8) eq 'compiled' or $file !~ /\Aa-zA-Z0-9]+\z/);The code should set $file to '_error' if the variable is not all 'a-zA-Z0-9', or if the variable begins with the word 'compiled'. The second example works fine, but my regex doesn't. Any help?
Edited by planetscape - added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Failed regex: negative look-behinds
by ikegami (Patriarch) on Feb 07, 2006 at 05:58 UTC | |
|
Re: Failed regex: negative look-behinds
by graff (Chancellor) on Feb 07, 2006 at 05:58 UTC | |
|
Re: Failed regex: negative look-behinds
by prasadbabu (Prior) on Feb 07, 2006 at 05:58 UTC | |
|
Re: Failed regex: negative look-behinds
by chargrill (Parson) on Feb 07, 2006 at 06:00 UTC | |
by loikiolki (Novice) on Feb 07, 2006 at 06:04 UTC | |
by chargrill (Parson) on Feb 07, 2006 at 06:11 UTC |