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
You could change the regex to use start/end anchors. Also, the trailing
comma in the length specifier bit means "4 or more" Eg:
if (preg_match("/^\d{4,}$/", $_POST['id'])){
echo $_POST['id'];
}
--
Richard Heyes
http://www.websupportsolutions.co.uk
Knowledge Base and Helpdesk software hosted for you - no
installation, no maintenance, new features automatic and free
** New Helpdesk demo now available **
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php