Here is a udf for removing words, it looks to see if the word is a certain
length before removing the word.


<cfscript>

function noWords(myText){

 var Words = "";
 var i = 1;
 var doRemove = false;
 var wordsToRemove = ArrayNew(1);
 var output = "";

 myText = LCASE(myText);

 //Words to remove
 wordsToRemove[1] = "an";
 wordsToRemove[2] = "the";
 wordsToRemove[3] = "at";
 wordsToRemove[4] = "by";
 wordsToRemove[5] = "for";
 wordsToRemove[6] = "of";
 wordsToRemove[7] = "in";
 wordsToRemove[8] = "up";
 wordsToRemove[9] = "on";
 wordsToRemove[10] = "to";
 wordsToRemove[11] = "and";
 wordsToRemove[12] = "as";
 wordsToRemove[13] = "but";
 wordsToRemove[14] = "if";
 wordsToRemove[15] = "or";
 wordsToRemove[16] = "nor";
 wordsToRemove[17] = "a";

 //Make each word in text an array variable

 Words = ListToArray(myText, " ");

 //Make sure words are not in the wordsToRemove list
 for(i=1; i LTE (ArrayLen(Words)); i = i+1){
  doRemove = false;

  //If the word is in the list, remove it
   if(ListFind(ArrayToList(wordsToRemove,","),Words[i])){
    doRemove = true;
   }
   //If doRemove eq true, remove the associated word.
    if(doRemove){
    Words[i] = "";
    }
  }
 output = ArrayToList(Words," ");

 return output;
}
</cfscript>




"Success is a journey, not a destination!!"



Doug Brown
----- Original Message -----
From: "Jochem van Dieten" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Sunday, April 07, 2002 5:01 AM
Subject: Re: Picking up swear words


> Kola Oyedeji wrote:
> > Try
> >
> > <cfset cleanString = RereplaceNoCase(dirtyString,
> > "[:space:]+ass[:space:]+",  "***" ,  "all" )>
> >
> > it should replace "ass" if it is preceded or followed by one or more
> > spaces/tabs but not as part of a word with "***" .
>
> But not if it is followed by control characters, punctuation etc.
> "[^[:alnum:]]+ass[^[:alnum:]]+" might be a better expression, but it
> will fail if the word you wish to filter is the first or the last word
> of the string. You might want to use something like below, but that
> would require some testing:
> "([^[:alnum:]]+|^)ass([^[:alnum:]]+|$)"
>
>
> Jochem
>
> 
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to