How can i convert:
ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", " ", $data);
to
preg_replace("......", " ", $data);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Everything you have in the regular expression appears to be valid for a perl regular expression. The difference is that perl regular expressions expect bounding characters (defined by the first character), and optional flags after the second bounding character (which I’ll ignore, see the PHP page for preg_match for their use).
In other words, an ereg match of
^\d$becomes/^\d$/, where/is the bounding character. If you start with a different character, that becomes the bounding character. This is useful, as in your case, when the usual bounding character of/is used heavily in the regular expression and you don’t want to have to escape it. For example,/^\d$/and|^\d$|are equivalent.In this specific case, you can use this as a preg_replace: