|
Posted by shimmyshack on 04/27/07 22:59
On Apr 27, 11:22 pm, Anthony Smith <mrsmi...@hotmail.com> wrote:
> I have data that is in this format: 8-8-19-29-1-4-41
> I wanted to write a simple function or regular expression that
> verified that data is in that format. The numbers should only be 1 or
> 2 digits. There should be 6 dashes (-) with 7 numbers around the
> dashes. Here are examples of bad data:
>
> 8-19-29-1-4-41 (Only 6 dashes)
> 5-1-2-3-4-S-67-4 (Includes a letter)
> 5-1-2-3-4-222-67-4 (has three digits in one space)
heres one using ereg
$var = '1-2-3-44-55-66-77';
if ( ereg( "^[0-9]{1,2}(-[0-9]{1,2}){6}$", $var ) )
{
//ok cos it starts with 1 or 2 characters from range 0-9,
//then has exactly 6 groups of - followed by 1 or 2 digits
}
[Back to original message]
|