sastro Posted September 7, 2010 Share Posted September 7, 2010 I need to convert eregi_replace to preg_replace. here is the code : $str = eregi_replace("((([ftp://])|(http(s?)://))((:alnum:|[-\%\.\?\=\#\_\:\&\/\~\+\@\,\;])*))"," ",$str); $str = eregi_replace("(([^/])www\.|(^www\.))((:alnum:|[-\%\.\?\=\#\_\:\&\/\~\+\@\,\;])*)"," ",$str); It is a script to remove url in string. Thanks in advanced Quote Link to comment Share on other sites More sharing options...
cags Posted September 8, 2010 Share Posted September 8, 2010 Are you sure that pattern is 100% correct even as a POSIX pattern? The square brackets around the ftp part means it likely doesn't do what you want it to do. There is a page in the documentation on the difference between POSIX and PCRE. Basically you will need to add delimiters (though in your case the unnecessary capture group around the whole pattern will actually work as the delimiters rather than a capture group, meaning it will run as is). The only other thing to remember is to add the i modifier since you are using eregi_. Should take you two minutes to fix using the PCRE section of the manual, but if you get stuck let us know. Quote Link to comment 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.