astralaaron Posted February 2, 2008 Share Posted February 2, 2008 how do you pregmatch something for letters and spaces only Link to comment Share on other sites More sharing options...
Synook Posted February 2, 2008 Share Posted February 2, 2008 preg_match("/[A-Za-z\s]/", $string); Link to comment Share on other sites More sharing options...
jhecht Posted February 2, 2008 Share Posted February 2, 2008 Synook's example will work for only 1 of the three. You need to set a minumum/maximum, which can be done a number of ways, just depends on what exactly you need the regex for. Link to comment Share on other sites More sharing options...
Synook Posted February 2, 2008 Share Posted February 2, 2008 Err? Link to comment Share on other sites More sharing options...
jhecht Posted February 2, 2008 Share Posted February 2, 2008 [a-zA-Z\s] only matches one of the characters. A user could input something like "E12345676543234566432" and it would work because theres a capital E there Link to comment Share on other sites More sharing options...
Synook Posted February 2, 2008 Share Posted February 2, 2008 Oh right, so it should be something more like ^[a-zA-Z\s]+$ Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.