in reply to match character in a set, then match one of the other ones

Is that your final answer?
  • Comment on Re: match character in a set, them match one of the other ones

Replies are listed 'Best First'.
Re^2: match character in a set, them match one of the other ones
by BrowserUk (Patriarch) on Aug 18, 2011 at 12:15 UTC
    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.

      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.