Search for similar string in string.

Discussion in 'PHP' started by imhawk, Sep 28, 2010.

  1. #1
    Hello,

    I'm working on advanced bad word filter and I was thinking about replacing SIMILAR words in the text.

    Such as example:
    - Bard word: 'shit'
    - Text: 'this is sh.it' or something else ... you get the point I guess.

    So, I would like to know how can I find the word "sh.it" and replace it with something else ...

    I know that function similar_text() in PHP exist and I know how to use it, but I can't figure it out, how to use it as search.

    Thanks!
     
    imhawk, Sep 28, 2010 IP
  2. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #2
    it is possible, but you have to make every rule
    like sh!t sh1t etc...
     
    gapz101, Sep 28, 2010 IP
  3. imhawk

    imhawk Well-Known Member

    Messages:
    615
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    140
    #3
    No, there should be any other way to do it. :)
    Creating word-list takes too much time ... :) but thanks for idea.
     
    imhawk, Sep 28, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    danx10, Sep 28, 2010 IP
  5. imhawk

    imhawk Well-Known Member

    Messages:
    615
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    140
    #5
    Thanks danx10, but I thought about that already. I just hoped there could be any other option. :p
    But what if I have two or more words to replace, and they need to be near each other, like for example: "shit eater"? I can't explode it and search for "shit" and "eater" since, I don't want to replace all "eater"s.

    Any good option how to simply that?
    I'll keep on trying.
     
    imhawk, Sep 29, 2010 IP
  6. imhawk

    imhawk Well-Known Member

    Messages:
    615
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    140
    #6
    Ok, I done it right this time. Exploding the words and looping is the right and I think the only way to do it.
    Thanks again!
     
    imhawk, Sep 29, 2010 IP
  7. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #7
    No problem
     
    danx10, Sep 29, 2010 IP