Does not match?

For pattern matching is there a does not match operator?
ie !=~ or !/value/

Comments

  • !~ instead of =~, I thought.

    If not, a way of emulating that would probabnly be something like /[^(regex)]/. I can't remember if grouping is allowed in character classes.
  • : !~ instead of =~, I thought.
    Yup, that's the one if you're binding...
    if ($a !~ /foo/) { ... }

    You can still use the ! (not) operator though.

    if (!($a =~ /foo/)) { ... }

    Which is messy in that case, but useful if you're matching against $_...

    if (! /foo/) { ... }

    : If not, a way of emulating that would probabnly be something like /[^
    : (regex)]/. I can't remember if grouping is allowed in character
    : classes.
    No, it's not. Brackets in a character class will be interpreted as literal brackets anyhow. Your example there would match a chracter that was not any of ( r e g x ).

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • : : !~ instead of =~, I thought.
    : Yup, that's the one if you're binding...
    : if ($a !~ /foo/) { ... }
    :
    : You can still use the ! (not) operator though.
    :
    : if (!($a =~ /foo/)) { ... }
    :
    : Which is messy in that case, but useful if you're matching against $_...
    :
    : if (! /foo/) { ... }
    :
    : : If not, a way of emulating that would probabnly be something like /[^
    : : (regex)]/. I can't remember if grouping is allowed in character
    : : classes.
    : No, it's not. Brackets in a character class will be interpreted as literal brackets anyhow. Your example there would match a chracter that was not any of ( r e g x ).
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

    Thanks guys! I can't see how I missed that.. monday mornings always get the best of me.

    David
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories