littlemonk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Need a regex..
by moritz (Cardinal) on May 22, 2012 at 09:48 UTC
      you mean !~, right?
      heh, ~= is not negated match :)
Re: Need a regex..
by marto (Cardinal) on May 22, 2012 at 11:17 UTC
Re: Need a regex..
by salva (Canon) on May 22, 2012 at 11:05 UTC
    if (index($str, 'Select') < 0) { ... }
Re: Need a regex..
by ikegami (Patriarch) on May 22, 2012 at 20:18 UTC

    It's unclear what you want.

    If you're trying to match «a string that isn't "Select"», you want

    $s !~ /^Select\z/

    If you're trying to match «a string that doesn't contain "Select"», you want

    $s !~ /Select/

    If you're trying to match «any number of characters that don't contain the substring "Select"», you want

    $s =~ /(?:(?!Select).)*/s

    (This last one would normally be used as part of a larger pattern.)


    /(?:(?!STRING).)*/s
    is to
    /STRING/
    as
    /[^CHAR]/
    is to
    /CHAR/
Re: Need a regex..
by Anonymous Monk on May 22, 2012 at 09:49 UTC
Re: Need a regex..
by zeni (Beadle) on May 22, 2012 at 10:45 UTC
    my $str = "#Select"; if ($str =~ m/^Select$/) { print "matched..\n"; } else { print "not matched..\n"; }
    output: not matched
Re: Need a regex..
by jack123 (Acolyte) on May 22, 2012 at 10:07 UTC
    Please correct your question you are trying to say accept or except. If its except then you can do any of these ways: $str = 'your regular expression string'; $str !~ /Select/