in reply to Regex failure interpretation

Syntax error. You ask for one char, you get one char. The + needs to be within the capture and then it works as advertised.

$_ =~ m[^([01]+)$] and print "$_:'$1'\n" for qw[ 0 1 00 11 10 01 012]; __DATA__ 0:'0' 1:'1' 00:'00' 11:'11' 10:'10' 01:'01'

cheers

tachyon

Replies are listed 'Best First'.
Re: Re: Regex failure interpretation
by BrowserUk (Patriarch) on Mar 20, 2004 at 00:40 UTC

    Not quite. As I mentioned above, I only want to capture the first character, not the whole string.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
      $_ =~ m/^([01])[01]*$/ and print "$_:'$1'\n" for qw[ 0 1 00 11 10 01 0 +12];

      cheers

      tachyon

        I knew that:)


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail