Forum Moderators: open

Message Too Old, No Replies

Filtering out 'naughty words' using regular expressions

         

digitalv

2:12 am on Aug 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First, thanks to everyone who has helped me with my previous RegEx questions - finally starting to get this stuff down. :)

I have a new question though that I'm sure someone has a solution for. I'm trying to create a "word scrubber" that will replace swear words with only the first and last letter and stars in the middle. So to keep the example clean, we'll pretend that the word 'luck' starts with an F...

"luck" or "l u c k" or "l.u.c.k" etc..

would be replaced with l**k

Is there any easy way to do this without having to guess every possible thing that someone might be trying to slip a bad word in?

mrMister

2:26 pm on Aug 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The following regex should do what you want...

l\W*u\W*c\W*k