How about transliteration?
if( $str =~ tr/_/_/ ) { print "with underscore\n"; } else { print "no underscore\n"; }
Or just for fun...
my $result = ( $str =~ tr/_/_/ ) ? "with " : "no "; print "$result underscore\n";
perlop explains the use of the tr/// operator.
Dave
In reply to Re: Regex for Differentiating Underscore and Whitespace
by davido
in thread Regex for Differentiating Underscore and Whitespace
by neversaint
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |