Re: regex matching exactly 10 digits
- From: "Mr P" <MisterPerl@xxxxxxxxx>
- Date: 28 Nov 2006 07:16:09 -0800
jtbutler78@xxxxxxxxxxx wrote:
I am having an issue trying to match exactly 10 digits. I want to
append a '1' in front of 10 digit fax numbers. Numbers longer than 10
digits leave alone. I am using \d{10,10} match at least and at most 10
digits but it still appends a 1 to international numbers. I am missing
something but I am not sure what.
#strip out unneeded chars
$fax_num =~ s/[\s()-]//g;
#append 1 to 10 digit fax number
$fax_num =~ s/(\d{10,10})/1$1/;
perhaps
s|^\d{10}$|1$1|;
although not knowing your delimiters, or if there can be more than one
10-digit # per scalar, it's difficult to say with certainty.
Have a nice holiday
.
- References:
- regex matching exactly 10 digits
- From: jtbutler78@xxxxxxxxxxx
- regex matching exactly 10 digits
- Prev by Date: Re: regex matching exactly 10 digits
- Next by Date: Re: regex matching exactly 10 digits
- Previous by thread: Re: regex matching exactly 10 digits
- Next by thread: Re: regex matching exactly 10 digits
- Index(es):
Relevant Pages
|