|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Problem with ReReplace
I can't seem to get this to work, any ideas?Andrew Grosset 05/05/04 02:08 P What are you trying to do?Barney Boisvert 05/05/04 02:23 P What do you think this will do?Jerry Johnson 05/05/04 02:18 P > What do you think this will do?Andrew Grosset 05/05/04 02:44 P I can't seem to get this to work, any ideas? <cfset other="\|(|)|{|}|[|]"> <cfset tmp = REReplaceNoCase(tmp,other,"","ALL")> 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 ----- 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")> > 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! 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
|
September 09, 2010
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||