• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

regular expression help

Explorer ,
Jan 27, 2007 Jan 27, 2007

Copy link to clipboard

Copied

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

TOPICS
Advanced techniques

Views

224

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 28, 2007 Jan 28, 2007
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 ac...

Votes

Translate

Translate
LEGEND ,
Jan 28, 2007 Jan 28, 2007

Copy link to clipboard

Copied

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


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation