Skip to main content
Inspiring
April 10, 2008
Question

Remove Random String...

  • April 10, 2008
  • 2 replies
  • 352 views
I need to find a sting in a block of text and remove it... How is this done?

For instance my text would be:
The quick brown fox jumped over the lazy dog.

I want to remove:
"quick brown fox" from that string...

Here is the catch, the string I want to remove will always start with "quick" and end with "fox", but "brown" may be blue, it may be green, it may be ugly, it may be anything... So in someway I need to have a script that looks for "quick" and looks for "fox" and remove those words and anything inbetween...

How is that done?

Thanks!!!
    This topic has been closed for replies.

    2 replies

    Inspiring
    April 10, 2008
    bweno wrote:
    >
    > How is that done?
    >
    > Thanks!!!
    >

    Regular expression is how this can be done.

    There is a lot to learn about regex, a simple example form you question:

    <cfset stuff = refind("quick.+brown","The quick brown fox jumped over
    the lazy dog.")>
    davidsimms
    Inspiring
    April 10, 2008
    Bweno,

    I'd probably use ColdFusion's REReplace() function (which requires understanding regular expression syntax), but you could also find the point at which "quick" ends and "fox" begins and use the RemoveChars() function to remove everything between the two.