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 Quote 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 (edited) $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. Edited February 18, 2013 by pkSML Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/274637-deprecated-eregi-statement/#findComment-1413644 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.