You are here: Re: Validating data « PHP Programming Language « IT news, forums, messages
Re: Validating data

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
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация