Mimi Cafe wrote:
I am trying to match words or complete phrase (excluding special characters) like:
Do you have a list of these special characters or do you mean all non-alphanumeric and non-whitespace:
#!/usr/bin/perl use strict; use warnings; while( <> ){ if( /[^[:space:][:alnum:]]/ ){ print "invalid: $_"; } } __END__
I need to ensure users cannot feed my program with special characters so I tried this below, but it doesn't match correctly.
You can escape Perl's meta-characters with quotemeta()or using \Q and \E in the regualr expression.
See: perldoc -f quotemeta http://perldoc.perl.org/functions/quotemeta.html perldoc perlretut http://perldoc.perl.org/perlretut.html perldoc perlre http://perldoc.perl.org/perlre.html -- Just my 0.00000002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. I like Perl; it's the only language where you can bless your thingy. Eliminate software piracy: use only FLOSS. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/