Richard Bagshaw wrote:
Howdi,
This one got me thinking, you could just match on something as simple
as /ass/gi but as you say this would also flag up "harassment" etc,
the only way I can see of doing this is either have a big list, or
only allow words through that have a-z characters on both sides of the
word.
So ... I wrote the following, and to test this I did have to include
some variations of nasty words, so I apologise for that now and would
just like to stress that swearing is not big || clever.
#!/usr/bin/perl
$sentance = 'you are a total harassment nastyfuckhead, and you fucking
need to fuck off and die you shitfaced twatshitface cunty nob!';
@words = $sentance =~ m/[A-Za-z]+/gi;
foreach(@words) {
# first check :: passes words that contain swear words as long as
# they have characters either side. ie (harassment).
# second check :: if the first check is passed then it checks
again
# for swear words.
# third check :: if it gets through to here then its assumemed
a nice
# word.
if (m/[a-zA-Z].*(ass|fuck|cunt|shit)[a-zA-Z].*/gi) {
print "Good Word [boxed] : $&\n";
} elsif (m/ass|fuck|cunt|shit/gi) {
print "Bad Word [found] : $_\n";
} else {
print "Good Word [passed] : $_\n";
}
}
This doesn't work that well either as some of those words are passed as
a good word, even though they are apparently, very vulgar....
SkyBlueshoes
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>