0

i found this code for checking a text area:

 if (strpos($textp, "http://") !== false ||
    ereg("(www.[a-zA-Z0-9_-]+)\.([a-zA-Z0-9.]+)",$textp)){
    $textp = '';
  } else {

because ereg is depreacted I would like to replacy by preg_match instead. But if I replace I got an error according to \ So what I should I exactly edit to get the same result - no URLs or elements of that inn that text area.

  • possible duplicate of [PHP: from ereg to preg\_match](http://stackoverflow.com/questions/8007779/php-from-ereg-to-preg-match) – Toto Feb 28 '14 at 08:09
  • Your regex matches url like: `http://www.----.....`, I'm not sure it's valid! – Toto Feb 28 '14 at 08:11
  • Possible duplicate of [How can I convert ereg expressions to preg in PHP?](https://stackoverflow.com/questions/6270004/how-can-i-convert-ereg-expressions-to-preg-in-php) – Toto Jun 03 '19 at 10:25

1 Answers1

0

you just need to add / like

  preg_match("/(www.[a-zA-Z0-9_-]+)\.([a-zA-Z0-9.]+)/",$textp)

please refer to preg_match