Jessica Posted December 29, 2006 Share Posted December 29, 2006 [code]if(!preg_match("/^[A-Za-z.]+$/", $this->username)){ $valid = 0;}else{ $valid = 1;}[/code]I also want to allow the - and a single space.Help? Link to comment https://forums.phpfreaks.com/topic/32217-solved-letters-spaces-and/ Share on other sites More sharing options...
wildteen88 Posted December 29, 2006 Share Posted December 29, 2006 just add them in the character range:[code][A-Za-z.-\s][/code] Link to comment https://forums.phpfreaks.com/topic/32217-solved-letters-spaces-and/#findComment-149554 Share on other sites More sharing options...
c4onastick Posted December 31, 2006 Share Posted December 31, 2006 Actually if you want to include the '-' character it needs to appear first in a character class (or escape it, since it has special meaning inside the class, as in 'A-Z').[code]if(!preg_match("/^[-A-Za-z.\s]+$/", $this->username)){ $valid = 0;}else{ $valid = 1;}[/code] Link to comment https://forums.phpfreaks.com/topic/32217-solved-letters-spaces-and/#findComment-150408 Share on other sites More sharing options...
Jessica Posted January 1, 2007 Author Share Posted January 1, 2007 Thanks! Link to comment https://forums.phpfreaks.com/topic/32217-solved-letters-spaces-and/#findComment-151060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.