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

Posted by Pedro Graca on 10/19/06 17:17

ollie.mitch@gmail.com wrote:
> So, basically, I want one expression that only lets in letters:
> ie. hyasdlhlasdhl but not fhdilfd7800asdads;'

Would you consider using preg_* instead of ereg?


Is "ñ" a letter? Is "" a string containing only letters?
Assuming 'yes' to both questions, try

if (preg_match('/^[[:alpha:]]*$/', $variable)) {
echo 'All letters.';
} else {
echo 'Not all letters.';
}

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

Can the string start or end with a (single) comma?
Assuming 'no', try

if (preg_match('/^[[:alpha:]]+(?:,[[:alpha:]]+)?$/', $variable)) {
echo 'Match';
} else {
echo 'No match.';
}

--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

 

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

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