develooper Front page | perl.beginners | Postings from February 2002

Re: reg exp question

Thread Previous | Thread Next
From:
Jeff 'japhy' Pinyan
Date:
February 7, 2002 08:44
Subject:
Re: reg exp question
Message ID:
Pine.GSO.4.21.0202071141210.15873-100000@crusoe.crusoe.net
On Feb 7, Stuart Clark said:

>How do I match a pattern that starts with a 4 and has 16 numbers in it.
> 
>I try /^4\d{16}/;

That's quite vague.  Do you mean the string must start with a 4 and
consist ONLY of 16 digits?

  /^4\d{15}$/

>Also  how do I match a 16 digit number that starts with either 6565 or
>starts with a number in the range of  555000-555100
> 
>/(^6565(\d{16})|^{555000-555100}(\d{16}))/

Again, you put \d{16} after you already matched some numbers.

  /^(?:6565\d{12}|555(?:0\d\d|100)\d{10})$/

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About