1

I have try to play around with preg_replace, but couldn't come up with a solution that fit all the exceptions

For example:

If the user enters "visit http://somewebsite.com"

(OR)

$text = "visit www . somewebsite . com";

(OR)

$text = "visit w w w dot somewebsite dot c o m";

Any idea?

Thanks in advance :)

karthi k
  • 51
  • 2
  • Are you trying to find this code in pages, or trying to eliminate them from spam for example? – RST Jun 17 '20 at 10:04
  • I'm trying to find these unwanted links. – karthi k Jun 17 '20 at 10:07
  • Does this answer your question? [Regular expression to find URLs within a string](https://stackoverflow.com/questions/6038061/regular-expression-to-find-urls-within-a-string) – Michel Jun 17 '20 at 10:09
  • 1
    Spammers will always find ways to bypass whatever someone comes up with. Since you need to detect them but not use them, I would probably go with take the message, remove all spaces, replace dot with . and then do a check on urls. This will result in false positives for sure, but might keep most of the spam links out. – RST Jun 17 '20 at 10:26
  • yeah got it ! thanks :) – karthi k Jun 17 '20 at 10:37

0 Answers0