Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Does not match?

davidrtgdavidrtg Posts: 95Member
For pattern matching is there a does not match operator?
ie !=~ or !/value/

Comments

  • WeirdofreakWeirdofreak Posts: 439Member
    !~ 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.
  • JonathanJonathan Posts: 2,914Member
    : !~ 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.");

  • davidrtgdavidrtg Posts: 95Member
    : : !~ 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.