A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Bad word filter too keen.........

  1. #1
    Junior Member
    Join Date
    Oct 2002
    Posts
    3

    Bad word filter too keen.........

    I am working on a bad word filter for an online chatroom which is working...... however it is also stopping words that contain a bad word.

    ie
    bad word that is banned - turd
    good word that is also banned - saturday

    the code i'm using is......

    if (this.message_txt.text.indexOf("turd") != -1)

    any ideas how to make the word ban so that it is precise and only bans the specific word.

    cheers
    J

  2. #2
    Mental Ward Patient Blips's Avatar
    Join Date
    May 2005
    Posts
    482
    check for the length of the string its checking, and see if its the length is the same as the word ur trying to block against.

  3. #3
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    It's not a perfect solution but you can add spaces before and after the offensive word and avoid partial matches inside other words. Things like punctuation will mess this up, but it's better than censoring saturday

    if (this.message_txt.text.indexOf(" "+turd+" ") != -1)

    As your bad word list grows this kind of solution is going to slow things down. You might want to look into a solution designed from the start to find multiple words in strings without rescanning the source string every time.
    Last edited by Northcode; 09-28-2005 at 11:35 AM.

  4. #4
    Member
    Join Date
    Jul 2001
    Posts
    66
    Not sure if this will help or not,

    http://actionscript.org/tutorials/in...ms/index.shtml

    Good luck

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center