Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm trying to replace the following using s// :

<input name="uid" type="checkbox" value="_8digits">
Where _8digits is a variable 8 digit number. How can I program this regex to match for any pattern with any 8 digits from 0 to 9 in that section?

Thanks,
Ralph.

update (broquaint): changed <font> to <code> tags

Replies are listed 'Best First'.
Re: Pattern matching with variable number
by CombatSquirrel (Hermit) on Sep 15, 2003 at 11:19 UTC
    Use m/\d{8}/, matching 8 digits in sequence.
    Cheers,
    CombatSquirrel.
    Entropy is the tendency of everything going to hell.
Re: Pattern matching with variable number
by LordWeber (Monk) on Sep 15, 2003 at 11:26 UTC
    Re: Pattern matching with variable number
    by dda (Friar) on Sep 15, 2003 at 11:21 UTC
      $s =~ /<input name="uid" type="checkbox" value="(\d\d\d\d\d\d\d\d)">/ && print "match found: $1\n";

      Probably you need to process optional spaces and carriage returns as well..

      Update: \d{8} is better :) Thanks CombatSquirrel!