Re: regex usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--- Valedol <Valedol@xxxxxxx> wrote:

> Is there a mothod to check string`s length with regex or the only
> way is  
> using strlen?
> 
> I want string consisting of 4 digits
> and check string with this code:
> 
> if (preg_match("/\d{4}/",$_POST[id]))
> { echo $_POST[id]; }
> 
> but preg_match  returns true when string consists of 4 or more
> digits
> -- 

To check only 4 digit, you have to specify max lengh of the string in
length specifier..

if (preg_match("/\d{4,4}/",$_POST[id]))
 { echo $_POST[id]; }

---
Nirmalya Lahiri
[+91-9433113536]


      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux