Moron Posted July 27, 2009 Share Posted July 27, 2009 This is probably dirt simple but I can't seem to think of the function at the moment (see my username). What function checks to see if a database field contains an alpha character? If a person has a middle initial, I want to put a period after it. If no middle initial, then no period. Thanks. Link to comment https://forums.phpfreaks.com/topic/167625-check-if-a-field-contains-an-alpha-character/ Share on other sites More sharing options...
zq29 Posted July 27, 2009 Share Posted July 27, 2009 Regular Expression? echo (preg_match("/^([A-Z]+)$/i",$str)) ? "Alpha" : "Not Alpha"; Link to comment https://forums.phpfreaks.com/topic/167625-check-if-a-field-contains-an-alpha-character/#findComment-883999 Share on other sites More sharing options...
Moron Posted July 27, 2009 Author Share Posted July 27, 2009 Regular Expression? echo (preg_match("/^([A-Z]+)$/i",$str)) ? "Alpha" : "Not Alpha"; Thanks. How would I use this against my database field? Link to comment https://forums.phpfreaks.com/topic/167625-check-if-a-field-contains-an-alpha-character/#findComment-884015 Share on other sites More sharing options...
vineld Posted July 27, 2009 Share Posted July 27, 2009 Regular Expression? echo (preg_match("/^([A-Z]+)$/i",$str)) ? "Alpha" : "Not Alpha"; Thanks. How would I use this against my database field? He probably meant to suggest that you will have to iterate through all rows and update accordingly using php. This is something you should to prior to inserting thereafter. Link to comment https://forums.phpfreaks.com/topic/167625-check-if-a-field-contains-an-alpha-character/#findComment-884018 Share on other sites More sharing options...
Moron Posted July 27, 2009 Author Share Posted July 27, 2009 Regular Expression? echo (preg_match("/^([A-Z]+)$/i",$str)) ? "Alpha" : "Not Alpha"; I see. Well... is there a way to just simply use a form of "not blank?" Thanks. How would I use this against my database field? He probably meant to suggest that you will have to iterate through all rows and update accordingly using php. This is something you should to prior to inserting thereafter. Link to comment https://forums.phpfreaks.com/topic/167625-check-if-a-field-contains-an-alpha-character/#findComment-884023 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.