Reply to Re: Regular expression

Your name:

Reply:


Posted by Steve on 10/17/07 17:55

<davranfor@gmail.com> wrote in message
news:1192638704.544026.253670@v29g2000prd.googlegroups.com...
> Hello
>
> I need a regular expression that validate a list of numbers separated
> by "-" , numbers can not be greater than 999
>
>
> Valid examples
> 0
> 12-455-01
> 1-9
> 125-32-155-45-45
>
> Invalid examples
> -1
> 45-
> 1-45665456-4
> 12-45-
> -

\d{4,}

if you do a preg_match, if any 4 or more contiguous digits are present, you
will get a match...and therefore, your list has numbers in it greater than
999...and is invalid. the dashes, then, become irrelevant.

don't forget, that's just the core pattern...you still need to add the / at
the beginning and end.

hth,

me

[Back to original 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

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