in reply to regular expression
As long as the same format of input string is used each time you can use a simple pattern substitution.
Substituting the first part of the number for as many digits as specified, then the middle part for as many digits as specified, and, finally the last part for as many digits as specified. By using the regexp incorporated pattern scalars s/(pat1)(pat2)/$1$2/.
use strict; my $Number = 4512872356698; print $Number."\n"; $Number =~ s/^(\d{6})(\d{3})(\d{4})$/$1XXX$3/; print $Number."\n"; exit 0;
The parentheses denote the pattern relating to the numbered scalar progressively. So the pattern inside the first parenthesis can be called by $1 in the substituting pattern, the pattern inside the second parenthesis can be called by $2 and so on.
Also note JavaFans use of the '+' symbol and the 'X x length' constructs
Coyote
|
|---|