[RESOLVED] regex help, matching $i number of numbers in $var - stuck
Results 1 to 3 of 3

Thread: [RESOLVED] regex help, matching $i number of numbers in $var - stuck

  1. #1
    Resident Kender kender's Avatar
    Join Date
    May 2004
    Location
    Great Lakes Region, USA
    Posts
    314

    resolved [RESOLVED] regex help, matching $i number of numbers in $var - stuck

    Okay, I am trying to check a $var for numbers, anywhere in the $var

    What I have is
    PHP Code:
    if(($number != 0) && (preg_match('/[0-9]{'.$number.'}/'$var) == 0))
    {
      
    // throw error

    Where $number is a user defined quantity of numbers that must be in the $var.. unfortunately this preg_match only checks for side by side, but it could be anywhere in the $var

    eg:
    PHP Code:
    $var 'fa5ba5rwbv';
    $number 2
    this should pass, but doesn't with my expression... but I can't find an example matching my specific need... can anyone help here?
    Now.

  2. #2
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,910
    PHP Code:
    $count preg_match_all('/[0-9]/'$var); 
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  3. #3
    Resident Kender kender's Avatar
    Join Date
    May 2004
    Location
    Great Lakes Region, USA
    Posts
    314
    that easy?! lol... I was making it more difficult than I needed to...

    Thanks Weedpacket!
    Now.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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