Results 1 to 4 of 4

Thread: Regular Expressions

  1. #1

    Thread Starter
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Regular Expressions

    Anyone out there any good at regular expressions?

    I need to check that an input only contains digits and is between 12 and 17 digits in length.

    I thought \d{12,17} would work but it only ensures there are between 12 and 17 digits grouped together i.e. if you append or preppend (is that a word?) other characters then it slips through.

    Help!

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Regular Expressions

    Add a string start and end anchor to it:

    ^\d{12,17}$

    (I think it's ^ and $, don't have regex here)

  3. #3

    Thread Starter
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: Regular Expressions

    Bang on Mr Frog!

    Cheers

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Regular Expressions

    Banging on

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width