This, should get a lot. Note here, that it's not a comprehensive block:
Code:
sub strip {
$your_text_line =~ s/(\S*(\.www|\.com|\.net|\.org)\S*)//gi;
}
( This detects a single word - any number of times. It starts with characters (\S = non whitespace), then ends with a domain type - followed by any number of characters - 0 or more. This will catch someone typing in something that resembles a URL - or a URL with some directory structure, even improperly formatted URLs. ( without the http part. ) The //gi - is the substitution part & modifiers. // = substitute with nothing. gi = global (g), ignore case (i). )
After the "org", you'll want to put a "|" then other domain types.
I want to also add, if your spammers are inserting domains, you might want to:
Code:
if ($text_line =~ /(\S*(\.www|\.com|\.net|\.org)\S*)//) {
die ("URL post detected, killing program"); # Quit program, don't post.
}
If you want to give it a spin - copy the top part of code, then make a few variable called "$your_text_line" with some examples of your spam posts:
Code:
$line = "hi this is my url http\:\/\/www\.google\.com please visit it.";
&strip;
print "$line \n";
#Repeat the top 3 lines any number of times to test, with every example you can think of.
sub strip {
$your_text_line =~ s/(\S*(\.www|\.com|\.net|\.org)\S*)//gi;
# After the end of each domain type, add another |\. - then a new domain type - like "fm" or "tv" -
# do as many as you can think of, or make one from a list of all domain types.
}