Part of the difficulty is describing the problem... sometimes the
description evolves as unanticipated results materialize.

Better description of problem:
Assemble a number of different strings with the final result being a single
string of words and phases that are delimited by commas. Strip out duplicate
words or phases in the result. Singular words are allowed in the phrases.

Could not the comma be used to distinguish between words and phrases? Would
be difficult to create a dictionary of all words that may be in original
string.

Will play with both Claude's and your suggestions.

Thanks,
Doug
----- Original Message -----
From: "Jim McAtee" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Sunday, May 16, 2004 1:03 PM
Subject: Re: Strip multiple words from string

> If, as you said, you're just putting together a keyword list, then take
> Claude's last suggestion.  However, distinguishing between a 'word' and a
> 'phrase', without knowing what constitutes a phrase (that is, wihout
> already having a dictionary of what you want to consider to be phrases) is
> going to be difficult or impossible.
>
> To answer your question... yes.  You'd first put together a keyword list
> and then remove duplicates of those keywords from your string.  But from
> the sounds of what you're trying to do, once you've put together the
> keyword list you're finished.
>
> Try this:
>
> <cfset s = "A string, or maybe not a string. Who knows? And who cares?">
> <cfset keywords = "">
> <cfloop index="w" list="#s#" delimiters=" .,?!;:%$&""'/|[]{}()">
>   <cfif not ListFindNoCase(keywords, w)>
>     <cfset keywords = ListAppend(keywords, LCase(w))>
>   </cfif>
> </cfloop>
> <cfoutput>
> <pre>
> s:        #s#
> keywords: #keywords#
> </pre>
> </cfoutput>
>
>
>
> ----- Original Message -----
> From: "DougF" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Sunday, May 16, 2004 1:28 PM
> Subject: Re: Strip multiple words from string
>
>
> > Sorry should have said:
> > "Is there a way to do this with 'OUT' having to specify the
> words/phrases to
> > search for"
> > -Doug
> > ----- Original Message -----
> > From: "DougF" <[EMAIL PROTECTED]>
> > To: "CF-Talk" <[EMAIL PROTECTED]>
> > Sent: Sunday, May 16, 2004 12:02 PM
> > Subject: Re: Strip multiple words from string
> >
> >
> > > Thanks Claude,
> > > Taking your suggestion I put this function together. My effort works
> in a
> > > simple way, but it is not a total solution to my problem...
> > > What I'm attempting to do is stitch together a number of different
> strings
> > > to create a keyword list. After the strings are assembled I need to
> strip
> > > out any duplicate words or phrases delimited by commas. Is there a way
> to
> > do
> > > this with having to specify the words/phrases to search for. RegExp's
> > maybe?
> > > Any suggestions?
> > >
> > > -Doug
> > > -----------------------
> > > <cfscript>
> > > function CleanKeywords(str){
> > > str = ReReplaceNoCase(str,"^[^[:alnum:]]*", "");// trims space at
> front
> > > str = rereplaceNoCase(str,"[^[:alnum:]]*$", "");// trims space at rear
> > > str = ReplaceNoCase(str,"Word_1","1x1x1x1");// replace first occurance
> of
> > > word with place holder word.
> > > str = ReplaceNoCase(str,"Word_2","2x2x2x2");
> > > str = ReplaceNoCase(str,"Word_3","3x3x3x3");
> > > // add addional words to find.
> > > str = ReplaceList(str,"Word_1,Word_2,Word_3",", , ,");// delete
> additional
> > > occurances of word.
> > > str = ReplaceNoCase(str,"1x1%1x1","Word_1");// restore original word
> at
> > > place holder word.
> > > str = ReplaceNoCase(str,"2x2%2x2","Word_2");
> > > str = ReplaceNoCase(str,"3x3%3x3","Word_3");
> > > // add addional words to restore.
> > > return str;
> > > }
> > > </cfscript>
> > >
> > > ----- Original Message -----
> > > From: "Claude Schneegans" <[EMAIL PROTECTED]>
> > > To: "CF-Talk" <[EMAIL PROTECTED]>
> > > Sent: Saturday, May 15, 2004 8:27 PM
> > > Subject: Re: Strip multiple words from string
> > >
> > >
> > > > Hmmmm, I think I would use the replace function to first replace the
> > first
> > > occurrence of the word by some string unlikely to be found in the
> text,
> > > like say "%*%*%*", then replace all remaining words by nothing, using
> > "all"
> > > , then but back the word at the place %*%*%* is.
> > > >  If you don't have too many words, the solution is workable.
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to