develooper Front page | perl.beginners | Postings from April 2002

RE:Regexp correction

Thread Previous
Felix Geerinckx
April 29, 2002 01:52
RE:Regexp correction
Message ID:
on Mon, 29 Apr 2002 08:40:13 GMT, (Jorge
Goncalvez) wrote: 

>  foreach (readdir(DIR)){
>         unless (/([Comm]+)/){
>             $box3->insert('end', $_);
>         }
>     }
>     closedir(DIR);

The [] signal a character class in a regex, meaning 'match any of the 
character between the '[]'. The '+' adds 'one or more times' to this.
The '()' are not needed here. They are used to group and/or to capture 
parts of the matched string into the special variables $1, $2, ...

If you only want to exclude a string with 'Comm' in it, you could write     
	unless (/Comm/) {...}



Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About