hi, has anyone a nice function to check if there is a valid url inside a string, probably some regular expressions (really not my strong side) or do you think a stristr($form, 'http://') PHP: is enought? some idiot tries to spam my side, but im happy to see his domain shut down by his provider after not even 6 hours
/:/ should return positive on any string containing an URL, but would also get a lot of false positives. If you want to check for Hypertext URLs your code would be sufficient.
Try it with preg_match: <?php // Host name preg_match("/^(http:\/\/)?([^\/]+)/i", $form, $matches); $host = $matches[2]; // domain preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches); $domain = $matches[0]; ?> PHP: