Jon, You cannot do that because the arguments of the REReplace() method are eveluated at the initial method execution time. Back references within a string are fine because they are evaluated within the inner working of the RERepalce() method. However, you cannot use them as part of another structure (ie, struct key) because that argument will be evaluated before the reg-ex replace actually even runs.
What you need to a algorithm that doesn't really do a replace but actually returns a structure of reg-ex groups. I threw this together in hopes that it might help: http://www.bennadel.com/blog/1040-REMatchGroups-ColdFusion-User-Defined- Function.htm Or- http://bennadel.com/index.cfm?dax=blog:1040.view ...................... Ben Nadel Certified Advanced ColdFusion MX7 Developer www.bennadel.com Need ColdFusion Help? www.bennadel.com/ask-ben/ -----Original Message----- From: Jon Clausen [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 14, 2007 8:40 PM To: CF-Talk Subject: Using reReplace Backreference as StructKey or Argument I'm sure it's something simple that I'm missing, but I want to use a regex backreference as the struct key (i.e. - struct["key"]) or as an argument (i.e. - function("argument") ) but I've failed in all my attempts so far. For now I've written the code out using a loop with reFind(), returning subexpressions, mid(), etc. but it seems to me there should be a way to do this using reReplace() and pass the backreference as an argument/key. Usage of evaluate() would probably be a deal-breaker since it would be less expensive to perform the loop. Here's examples of what i'm trying to do: <!--- Trying to use backref passed as struct key ---> <cfset pageOut = reReplace(pageContent,"<%show:([a-zA-Z0-9_]+) %>",appSettings["\1"],"ALL")/> <!--- Trying to use backref passed as argument ---> <cfset pageOut = reReplace(pageContent,"<%getModule:([a-zA-Z0-9_]+) %>",controller.getModule("\1"),"ALL")/> Thoughts? Jon ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:293397 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

