Reply to Re: [PHP] can you solve this problem with regex ?

Your name:

Reply:


Posted by Marek Kilimajer on 01/17/05 12:27

Zouari Fourat wrote:
> Hello !
> My user can input values like this :
>
> 15.2
> 10-5
> 10 0
> 0x5
> 005
> 00
>
> to be clear, i must extract two values from each line, each value is
> between 1 and 20 and seaparated with a non numeric caracter, so with
> lines 1,2,3 and 4 i will get :
>
> Array([0]=>15, [1]=>2);
> Array([0]=>10, [1]=>5);
> Array([0]=>10, [1]=>0);
> Array([0]=>0, [1]=>5);
>
> and for other lines i will label them as erronus entries...
>
> how can i do it intelligently :)
>

yes.

if(!preg_match('/^([0-9]+)[^0-9]+([0-9]+)$/', $input, $m)) {
$m = 'error';
}

print_r($m);

[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

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