halosinfire Posted June 1, 2013 Share Posted June 1, 2013 I've never quite understood the syntax of preg_replace and now I need to convert the following line of code from ereg_replace to preg_replace because ereg_replace is deprecated. Can anyone help? $qstr = ereg_replace("&page=[0-9]+","",$_SERVER['QUERY_STRING']); Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/278654-change-ereg_replace-to-preg_replace-syntax/ Share on other sites More sharing options...
Solution requinix Posted June 1, 2013 Solution Share Posted June 1, 2013 For a lot of expressions all you need to do is add delimiters. Most anything will do but / and # are most common. /&page=[0-9]+/For eregi methods use the /i flag like /&page=[0-9]+/i. Quote Link to comment https://forums.phpfreaks.com/topic/278654-change-ereg_replace-to-preg_replace-syntax/#findComment-1433511 Share on other sites More sharing options...
halosinfire Posted June 1, 2013 Author Share Posted June 1, 2013 Thank you very much requinix, that works perfects =) Quote Link to comment https://forums.phpfreaks.com/topic/278654-change-ereg_replace-to-preg_replace-syntax/#findComment-1433515 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.