The regexp is correct. The problem is your string. Use single quote instead of double quote, to avoid interpolation. Try this code:
{ my $name = "s@--__"; print $name, "\n"; if ($name =~ /\A[a-zA-Z][\w.-]*\z/) { print "match\n"; } else { print "not match\n"; } } { my $name = "s!!!@@@___"; print $name, "\n"; if ($name =~ /\A[a-zA-Z][\w.-]*\z/) { print "match\n"; } else { print "not match\n"; } } { my $name = 's@--__'; print $name, "\n"; if ($name =~ /\A[a-zA-Z][\w.-]*\z/) { print "match\n"; } else { print "not match\n"; } } { my $name = 's!!!@@@___'; print $name, "\n"; if ($name =~ /\A[a-zA-Z][\w.-]*\z/) { print "match\n"; } else { print "not match\n"; } }
Which prints:
Possible unintended interpolation of @___ in string at math1.pl line 1 +1. s-__ match s!!!@@ not match s@--__ not match s!!!@@@___ not match
In reply to Re: how to state this by REL
by pg
in thread how to state this by REL
by whatluo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |