Re: regular expression for integer range

From: Date: Tue, 06 Sep 2005 18:17:12 +0000
Subject: Re: regular expression for integer range
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-221918@lists.php.net to get a copy of this message
On Tue, 6 Sep 2005, babu 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.
ereg("^[-0-9,]+$"... would do it, but it would also allow "10,-" as a valid expression as well.. so if you want to check for valid ranges you'll want to beef that up a bit... -philip

« previous php.general (#221918) next »