3 Replies Latest reply on Dec 13, 2007 8:40 AM by Newsgroup_User

    Regular Expression in CF ?

    rambo
      Hi

      I have the following line from an rss feed

      #weather_xml.rss.channel.item[x].description.xmlText#

      At present it outputs as

      Thursday: sunny, Max Temp: 8°C (46°F), Min Temp: 4°C (39°F)

      Is it possible using regular expressions or another method, that after each comma the script will insert a <br> tag so all the data is not displayed on one line ?

      Any ideas ?
        • 1. Re: Regular Expression in CF ?
          TSB
          replace(weather_xml.rss.channel.item[x].description.xmlText, ',', '<br>', 'ALL'>

          I think that is the correct syntax for it.

          T
          • 2. Re: Regular Expression in CF ?
            rambo Level 1
            Thanks

            I have tried

            REReplace(#weather_xml.rss.channel.item[x].description.xmlText#, ',', '<br>', 'ALL')

            But on the page it shows up as normal text i.e.
            REReplace(Max Temp: 8°C (46°F), Min Temp: 4°C (39°F), Wind Direction: SSE, Wind Speed: 14mph, Visibility: moderate, Pressure: 1038mb, Humidity: 88%, UV risk: low, Sunrise: 08:12GMT, Sunset: 16:06GMT, ',', '
            • 3. Re: Regular Expression in CF ?
              Level 7
              rambo wrote:
              > But on the page it shows up as normal text i.e.
              > REReplace(Max Temp: 8?C (46?F), Min Temp: 4?C (39?F), Wind Direction: SSE,
              > Wind Speed: 14mph, Visibility: moderate, Pressure: 1038mb, Humidity: 88%, UV
              > risk: low, Sunrise: 08:12GMT, Sunset: 16:06GMT, ',', '

              You do have to provide the basic CFML syntax of hash|pound|# signs
              around the function inside a <cfoutput></cfoutput> block so that the
              ColdFusion application server knows this is a statement to be resolved,
              not just text to display.

              I.E.
              <cfoutput>#replace(weather_xml.rss.channel.item[x].description.xmlText,
              ',', '<br>', 'ALL'>#</cfoutput>