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
In reply to Failed regex: negative look-behinds by loikiolki
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |