Reply to Re: Regular expression

Your name:

Reply:


Posted by Rik Wasmus on 10/18/07 11:44

On Thu, 18 Oct 2007 10:42:20 +0200, <davranfor@gmail.com> wrote:
> Same but numbers can't be lesser than the previous number, must be
> equal or greater, is this possible with regex??
>
> 0-45-90-120 -> Valid
> 0-45-45-90 -> Valid
> 0-90-45-120 -> Invalid

Maybe it's possible. I wouldn't do it with a regex anymore though.

function _my_validate($string){
$array =3D explode('-',$string);
if(!is_array($array)) return false;
$previous =3D 0;
foreach($array as $value){
if(
intval($value)!=3D $value
||
$value < $previous
||
$value > 999
) return false;
$previous =3D $value;
}
return true;
}


-- =

Rik Wasmus

[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

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