1 Reply Latest reply on Jan 28, 2007 1:43 PM by Newsgroup_User

    regular expression help

    dandev
      I';m trying to implement a search on my site and I want to take in account plurals. I found the file in rails that handle this and since I have a real hard time with reg expressions i need help translating to cf

      plural(/([m|l])ouse$/i, '\1ice')

      This take "mouse" and returns "mice". How would this line be written in cf?

      Thanks

        • 1. Re: regular expression help
          Level 7
          here you go. it's quite similar. i'm guessing the /i in the rails version
          means case-insensitive.

          <cfset mouse = "mouse">

          <cfset louse = "louse">

          <cfset mice = reReplaceNoCase(mouse,"(m|l)ouse","\1ice","all")>

          <cfset lice = reReplaceNoCase(louse,"(m|l)ouse","\1ice","all")>

          <cfoutput>

          #mice#<br>

          #lice#

          </cfoutput>




          "dandev" <webforumsuser@macromedia.com> wrote in message
          news:epfsd4$pfs$1@forums.macromedia.com...
          > I';m trying to implement a search on my site and I want to take in account
          > plurals. I found the file in rails that handle this and since I have a
          > real
          > hard time with reg expressions i need help translating to cf
          >
          > plural(/([m|l])ouse$/i, '\1ice')
          >
          > This take "mouse" and returns "mice". How would this line be written in
          > cf?
          >
          > Thanks
          >
          >
          >