How can i filter single words out ?
i have a small text taken from an editfield and like to filter some bad words out before i submit the text.
for this i need to get all words ,word by word to look for them in the bad word list.
sometime the user can make more then one space so checking for a empty place inside two words or a singel "," is not so good.
what i need is a good idea what i should do...my brain is empty after testing the upper 2 ways :-(

Thanks
Posted on 2001-12-14 09:48:21 by Max
Personaly, i would use a substring search method, just like C strstr does(win32 version available in shlwapi.lib) and search the whole buffer for the words.

You can also code your own function, make it case insensitive, etc...
Posted on 2001-12-14 09:59:57 by JCP
Get a book about algorithms - if you've got money I would recommend Knuth's Art of Programming.

Or you could use a finite state machine like this.

you go through the text byte by byte. The first state enters the second one, whenever it encounters a start of a "bad" word.
The 2nd state enters 3rd if it encounters 2nd char of !that! bad word. And so on.

For exmaple you want to find carl, truck and cart

sequence: ...bcarta...

you start with: b -> not starting letter (not c, not t)
go to next
c-> part of carl, cart
a->part of carl, cart
r->part of carl, cart
t-> cart - found one - now do what you want

remember - whenever you realize you made a mistake, return to starting state and then go on with the next char to the one you started with last time.

had it been carb:

c, a, r, hits, b-> no hit return to starting state, go on with !a!
Posted on 2001-12-18 11:25:44 by iso8859-1
C:\masm32\M32LIB\INSTRING.ASM
Posted on 2001-12-18 19:28:05 by grv575