Skip to main content
Inspiring
August 1, 2008
Question

Regular expression question

  • August 1, 2008
  • 1 reply
  • 277 views
Hi All,
I want to take out a part of text from a string. Like
"This is a sample of regular expression ok message sample ok dude"
Result should be "This is a message sample ok dude"
I try this
<cfset temp = "This is a sample of regular expression ok message sample ok"
<cfset temp1 = #REReplace(temp, '(sample).*(ok)',"")#>

But it deletes until the last "ok" like "This is a dude"
Can anyone help?
Thanks

JFB


This topic has been closed for replies.

1 reply

Inspiring
August 1, 2008
Sometime I need to write to see the solution.
I got it.
<cfset temp1 = #REReplace(temp, '(sample).+?(ok)',"")#>

Is this a good solution?
Thanks

JFB



"JFB" <jfb@help.com> wrote in message
news:g6vskv$lnl$1@forums.macromedia.com...
> Hi All,
> I want to take out a part of text from a string. Like
> "This is a sample of regular expression ok message sample ok dude"
> Result should be "This is a message sample ok dude"
> I try this
> <cfset temp = "This is a sample of regular expression ok message sample
> ok"
> <cfset temp1 = #REReplace(temp, '(sample).*(ok)',"")#>
>
> But it deletes until the last "ok" like "This is a dude"
> Can anyone help?
> Thanks
>
> JFB
>
>
>