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

Hi monks, i found some excersises on inet when i was learning about regex the first have to match in a file this character "x" "the" or "The" and type in front of the line a number like "001" and so on, the scripts goes like this:
#!/usr/bin/perl -w use scrict; open(INFO,"file.txt"); $cont="001"; while(<INFO>){ chomp(); if ( /x|(t|T)he/ ) { print "$cont $_";$cont++ } print "\n"; } close INFO;
now the other script needs to match any character repetetion i tried with the boundary scape sequence but i did not get any result here is my regex:
/\b\w.\b/
wating for the help, and thx

Replies are listed 'Best First'.
Re: Regexp Problems
by Zaxo (Archbishop) on Dec 16, 2002 at 12:39 UTC
    /(\w)\1/ # matches a repeated word character /(.)\1/ # matches any but mewline repeated

    You can change behavior some more with modifier like /g for global or /s to let '.' match newlines. The \1 metacharacter refers to the first captured match.

    After Compline,
    Zaxo