On 9/6/05, babu <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> 
> I want to write regular expression for checking the string format entered by 
> user.
> 
> the allowed formats are
> 
> examples:
> 10
> 10,
> 10,12-10
> 12-10
> 
> that is the valid strings are:
> 1. only integer
> 2. an integer, range of integers example 3
> 
> and no other characters must be allowed.

$re = '/^(\d+)(,\d+-\d+)?$/';
preg_match($re, $value);

This only allows
 * an integer or
 * an integer followed by a comma and a range of integers

It doesn't allow anything else - even whitespace after the comma.

 -robin

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

Reply via email to