1 Reply Latest reply on Aug 1, 2008 1:55 PM by Newsgroup_User

    Regular expression question

    Level 7
      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


        • 1. Re: Regular expression question
          Level 7
          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
          >
          >
          >