Skip to content
MSN

Word Filter Check Help Needed.

A TG007 community discussion started by Warrior124.

Discussion 6 posts
Page 1 of 1
Open
Topic #5329 · 6 published posts · 558 views

I was wondering how can one check for incoming text against words you have in a text file, such as when you get the text "Testing", and you only have the word "Test" in a text file? Then, the script would block the entire word "Testing". Here is the code I have at the moment...

 

alias filter {
 if (%ifilter == $true) {
   var %i = 1
   var %filtered = $1-
   while ($gettok($1-,%i,32)) {
     var %filt = $gettok($1-,%i,32)
     if ($read(filteredwords.txt,w,* $+ %filt $+ *)) { var %filtered = $replace($1-,$gettok($1-,%i,32),) }
     inc %i 
   }  
   return %filtered
 }
 else return $1-
}

You have to work the other way around then.

You should check all the words from the file and look if they are in (a part of a word of) the typed text.

Personally i found it easier to use ini files

I can use the following to add words

 

*test

*test*

test*

test

 

it will see all those in mine

 

Edited Nov 26, 2005 10:46 AM by Ozzy10

My code does NOT have bugs. It just develops random features.

This one should filter words that are in the file or that begin with it.

alias filter {
 var %i = 1, %m = $lines(filteredwords.txt), %in = $1-, %s
 while (%i <= %m) {
   %s = $regsub(%in,/(\b $+ $read(filteredwords.txt,%i) $+ \S*\b)/gi,,%in)
   inc %i
 }
 return %in
} 

TY, Petertje. That works great. :)

No problem. Don't forget if you use it on all on text events, it can become I/O consuming.

You could consider putting the words in a hash table.