|
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]
|