Can one (or more to the point, I) use a variable as a quantifier value in a regex ? As illustrated in below...
#!/usr/bin/perl -w use constant minUC => 3; my $min = 3; my $test = "AAAAAA"; my @chars = (split //, $test); my $Rep = 0; foreach my $c ( @chars) { $Rep++ if ($test =~ /$c{3,}?/) ; # this works # $Rep++ if ($test =~ /$c{$min,}?/) ; # no work; # $Rep++ if ($test =~ /$c{minUC,}?/) ; #nor does using a named cons +tant }
In reply to variable quantifiers? by FryingFinn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |