House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Problem with ReReplace

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andrew Grosset
05/05/2004 02:08 PM

I can't seem to get this to work, any ideas? <cfset other="\|(|)|{|}|[|]"> <cfset tmp = REReplaceNoCase(tmp,other,"","ALL")>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Barney Boisvert
05/05/2004 02:23 PM

What are you trying to do? If you're trying to remove all the slashes, parens, brackets and braces, then you'll need to escape those characters, as they have special meaning in regular expressions.  Try this one: <cfset other = "\\|\(|\)|\{|\}|\[|\]" /> You can also make this a easier by using a character class: <cfset other = "[\\[\]{}()]" /> Finally, you don't need the NoCase version, since you're not using letters. Cheers, barneyb ----- Excess quoted text cut - see Original Post for more -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jerry Johnson
05/05/2004 02:18 PM

What do you think this will do? Are you trying to remove all the brackets? Are the | meant to be ORs? If so, this might do it. We build a class out of the puncuation you want to remove. The [] need to be handled seperately since they are special and can't be placed in a class. <cfset other="[\(){}]"> <cfset tmp = REReplaceNoCase(tmp,other,"","ALL")> <cfset tmp = ReplaceNoCase(tmp,"[","","ALL")> <cfset tmp = ReplaceNoCase(tmp,"]","","ALL")> I am sure someone smarter will show you a better way. Mr. Doom? Jerry Johnson >>> rushglen@yahoo.com 05/05/04 02:07PM >>> I can't seem to get this to work, any ideas? <cfset other="\|(|)|{|}|[|]"> <cfset tmp = REReplaceNoCase(tmp,other,"","ALL")>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andrew Grosset
05/05/2004 02:44 PM

> What do you think this will do? > > Are you trying to remove all the brackets? Are the | meant to be ORs? > Many thanks, I was trying to remove the brackets and I thought they had to be seperated by |. Your solution works great!

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jerry Johnson
05/05/2004 02:51 PM

Glad to hear it.  If you are using CFMX, the second response was much better. But I don't think it will work correctly on CF5 or earlier. Jerry Johnson


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

September 09, 2010

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30