You can simply #2 a a bit:
That rx can be built dynamically as follows:$rx_4333 = /(?=\d{4}$) (?: 4 (?: 3 (?: 3 [3-9] | [4-9] ) | [4-9] ) | [5-9] ) $/x
my @digits = $ProdBuild =~ /([0-9])([0-9])([0-9])([0-9])$/; my $rx = '(?=\\d{4}$)'; for (@digits) { $rx .= "(?:$_"; } for (reverse @digits) { local $_ = $_+1; $rx .= '|' . ($_ == 9 ? 9 : "[$_-9]") if $_ != 10; $rx .= ')'; } # 4333 gives (?=\d{4}$)(?:4(?:3(?:3(?:3|[4-9])|[4-9])|[4-9])|[5-9]) foreach (@pattern) { print("Match: $_\n") if /$rx/; }
Update: I cleaned up the regexp building code a bit, at the cost of a little redundancy in the regexp. For example, a last digit of 3 results in 3|[4-9].
In reply to Re^2: Regular expression patter matching question
by ikegami
in thread Regular expression pattern matching question
by ramya2005
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |