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);
But this only appears to be checking the first character.
I also have no idea how to do the one that also allows commas (though
not for lack of trying - believe me!)
So, basically, I want one expression that only lets in letters:
ie. hyasdlhlasdhl but not fhdilfd7800asda ds;'
and one expression that only lets in letters and commas (one at a
time):
ie. hasiaks,asdas,a dsads but not hdasl,,ahodsa,a ds
Thanks alot.
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);
But this only appears to be checking the first character.
I also have no idea how to do the one that also allows commas (though
not for lack of trying - believe me!)
So, basically, I want one expression that only lets in letters:
ie. hyasdlhlasdhl but not fhdilfd7800asda ds;'
and one expression that only lets in letters and commas (one at a
time):
ie. hasiaks,asdas,a dsads but not hdasl,,ahodsa,a ds
Thanks alot.
Comment