Re: regex matching exactly 10 digits




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

.



Relevant Pages

  • Re: regex matching exactly 10 digits
    ... append a '1' in front of 10 digit fax numbers. ... digits leave alone. ... certain sorts of tools at low cost and in short order. ...
    (comp.lang.perl.misc)
  • Re: regex matching exactly 10 digits
    ... John W. Krahn wrote: ... append a '1' in front of 10 digit fax numbers. ... digits leave alone. ...
    (comp.lang.perl.misc)
  • Re: regex matching exactly 10 digits
    ... Paul Lalli wrote: ... append a '1' in front of 10 digit fax numbers. ... You are checking only to see if the string *contains* the ...
    (comp.lang.perl.misc)
  • Re: regex matching exactly 10 digits
    ... append a '1' in front of 10 digit fax numbers. ... You are checking only to see if the string *contains* the ...
    (comp.lang.perl.misc)