in reply to regex hell

You're mistaking character class negation for "doesn't match".

[^a-z] means "Match a single character that is not a through z." But it doesn't mean "target may not contain a-z." If that's your intention, you might accomplish it like this:

if( $plat !~ m/[a-z]/ ) { ....

Or...

if( $plat =~ m/^[^a-z]*$/ ) { ...

The former simply says "If target doesn't match a-z." The second says, "If target matches a string that contains any amount of anything except for a-z."


Dave

Replies are listed 'Best First'.
Re^2: regex hell
by diotalevi (Canon) on Mar 01, 2006 at 01:58 UTC

    Your second example is horrible. Say not /[a-z]/, never /^[^a-z]*$/.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊