lkeeney Posted February 18, 2013 Share Posted February 18, 2013 I know next to nothing about this part of PHP. However I was able to generate a rather large application form using eregi statements that worked fine until they deprecated the eregi statement. I understand I should use the preg_match statement but I can't get it to work on my form. Here is the first statement in my form: $string_exp = "^[a-z .'-]+$"; if(!eregi($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.';} Can someone tell me how to convert this to a preg_match statement? Or if there is another better method please let me know. Lawrence Link to comment https://forums.phpfreaks.com/topic/274637-deprecated-eregi-statement/ Share on other sites More sharing options...
pkSML Posted February 18, 2013 Share Posted February 18, 2013 $string_exp = "@^[a-z .'-]+$@i"; if(preg_match($string_exp,$first_name) == 0) { $error_message .= 'The First Name you entered does not appear to be valid.';} Give that a whirl. Edit: added the "i" PCRE switch to make it caseless. Link to comment https://forums.phpfreaks.com/topic/274637-deprecated-eregi-statement/#findComment-1413162 Share on other sites More sharing options...
lkeeney Posted February 20, 2013 Author Share Posted February 20, 2013 Thank you for your help. Link to comment https://forums.phpfreaks.com/topic/274637-deprecated-eregi-statement/#findComment-1413644 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.