Scot Robnett wrote at Tue, 04 Jun 2002 05:13:13 +0200: >> $foo =~ s/\W*/_/g; >> >> http://www.oreilly.com/catalog/regex/ > ... > > I want to allow only the a-z, A-Z, and 0-9 characters and I want to replace all >others with _ when > writing the file to the server. > > Can you tell me what would be this regular expression? >
The regexp should be $foo =~ s/\W/_/g; \W* matches every zero length, so e.g. $a = 'x := y'; $a =~ s/\W*/_/g; print $a; prints _x__y_; (first matches 0-length before 'x', then ' := ' after x, then 0-length between ' := ' and 'y', then 0-length after 'y' ) Instead my solution would print x____y Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]