Re: regex matching exactly 10 digits
- From: bugbear <bugbear@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 15:29:53 +0000
Paul Lalli wrote:
#append 1 to 10 digit fax number
$fax_num =~ s/(\d{10,10})/1$1/;
You are missing the fact that a regexp doesn't care what *else* is in
the string. You are checking only to see if the string *contains* the
pattern. "At most" does not mean that the string cannot contain more
of that token. It means that this particular piece of the regexp will
not match more than that many. You need to explicitly check that
another digit neither precedes nor follows the ten that you've found:
Depending on the OP's data, the simpler
match
/^\d{10,10}$/
may serve.
BugBear
.
- Follow-Ups:
- Re: regex matching exactly 10 digits
- From: Dr.Ruud
- Re: regex matching exactly 10 digits
- References:
- regex matching exactly 10 digits
- From: jtbutler78@xxxxxxxxxxx
- Re: regex matching exactly 10 digits
- From: Paul Lalli
- 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
|