in reply to Re: match character in a set, them match one of the other ones
in thread match character in a set, then match one of the other ones

Is that your final answer?

Sorry, I just noticed this. Is that question aimed at you, me, or the world in general?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^2: match character in a set, them match one of the other ones

Replies are listed 'Best First'.
Re^3: match character in a set, them match one of the other ones
by 7stud (Deacon) on Aug 18, 2011 at 20:11 UTC

    At you. moritz provided the fix. In addition to moritz's correction, you can also clean up your regex by eliminating the extraneous parentheses, which just serve to obfuscate what is going on:

    use strict; use warnings; use 5.010; my @strings = ( 'aa', 'ab', 'a1', ); for my $str (@strings) { if ($str =~ / ([a-z]) (?!\1) [a-z] /x ) { say "$str: $1"; } } --output:-- ab: a

    Thanks.