You are here: Re: Simple ereg help « PHP Programming Language « IT news, forums, messages
Re: Simple ereg help

Posted by Rik on 10/19/06 14:41

ollie.mitch@gmail.com wrote:
> Hi,
>
> I need two ereg expressions in my PHP code. One of them needs to check
> that a string only contains letters, and the other needs to check that
> the string only contains letters and commas (only one comma at each
> time).
>
> I thought that the code for only containing letters would be:
>
> eregi("^([a-z])", $keywords);

Use the preg-variant, it's faster.

preg_match('/^[a-z]+$/i',$text);

> and one expression that only lets in letters and commas (one at a
> time):
> ie. hasiaks,asdas,adsads but not hdasl,,ahodsa,ads

preg_match('/^[a-z]+(,[a-z]+)*?$/i',$text(;

Grtz,

--
Rik Wasmus

 

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

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