Dear All,
my $tmp="*3f4#_#33#"
if ($tmp =~ tr/*// > 1 || $tmp =~ tr/#// > 2) {
print "yes";
}
any possible to combine both regular expression into one?
Thanks
Dear All,
my $tmp="*3f4#_#33#"
if ($tmp =~ tr/*// > 1 || $tmp =~ tr/#// > 2) {
print "yes";
}
any possible to combine both regular expression into one?
Thanks
With the below code, you would have to compromise on greater-than-2 condition:
my $tmp="*3f4#_#33#";
if ($tmp =~ s/[*#]//g > 1) {
print "yes\n";
}
tr
is not really using regular expression. It just replaces/deletes characters from the string. Also you can't really combine this expressions into single "tr" or even single "s///" as you are checking the number of different characters removed.
Thanks all, btw, i cannot combine both rules into >2, each one has it is own rule, just having the same $tmp.