Question
REReplaceNoCase
hi,
thanks for helping me. i am kinda trying to write a reg. expressions and not working well.
i have a script where i am trying to read in CF and change its variables and its usage.
In the following script/variable list I only want to replace variable (i.e., LX) with M1 and LX with M2...
I want to write a Reg. Expression to replace on these conditions
if a varaible is preceded by a Space or a Comma or a Open Paren ("(")
or if a varibale is followed by a Space or a Comma or a Close Paren (")")
I also want to replace in OUTSTR variables replaced only if the string is outside the Quotes.
Thanks for your help.
Regards,
sc
<CFSET VARARRAY= ArrayNew(1)>
<CFSET CHGARRAY= ArrayNew(1)>
<CFSET VARARRAY[1] = "LX"> <CFSET CHGARRAY[1] = "M1">
<CFSET VARARRAY[2] = "LX2"> <CFSET CHGARRAY[2] = "M2">
<CFSET VARARRAY[3] = "RX"> <CFSET CHGARRAY[3] = "T1">
<CFSET VARARRAY[4] = "RX2"> <CFSET CHGARRAY[4] = "T2">
<CFSET CODESTR = "callFunction( LX, RX, LX2, RX2 )">
<CFLOOP INDEX = "DX" FROM=1 TO=4>
<CFSET CODESTR = REReplaceNoCase(CODESTR, VARARRAY[DX], CHGARRAY[DX]>
</CFLOOP>
<CFSET OUTSTR = 'print(" LX = ", LX, " LX2 = ", LX2, " RX = ", RX, " RX2 = ", RX2);'>
<CFOUTPUT>
#CODESTR# <br>
#OUTSTR#<br>
</CFOUTPUT>
thanks for helping me. i am kinda trying to write a reg. expressions and not working well.
i have a script where i am trying to read in CF and change its variables and its usage.
In the following script/variable list I only want to replace variable (i.e., LX) with M1 and LX with M2...
I want to write a Reg. Expression to replace on these conditions
if a varaible is preceded by a Space or a Comma or a Open Paren ("(")
or if a varibale is followed by a Space or a Comma or a Close Paren (")")
I also want to replace in OUTSTR variables replaced only if the string is outside the Quotes.
Thanks for your help.
Regards,
sc
<CFSET VARARRAY= ArrayNew(1)>
<CFSET CHGARRAY= ArrayNew(1)>
<CFSET VARARRAY[1] = "LX"> <CFSET CHGARRAY[1] = "M1">
<CFSET VARARRAY[2] = "LX2"> <CFSET CHGARRAY[2] = "M2">
<CFSET VARARRAY[3] = "RX"> <CFSET CHGARRAY[3] = "T1">
<CFSET VARARRAY[4] = "RX2"> <CFSET CHGARRAY[4] = "T2">
<CFSET CODESTR = "callFunction( LX, RX, LX2, RX2 )">
<CFLOOP INDEX = "DX" FROM=1 TO=4>
<CFSET CODESTR = REReplaceNoCase(CODESTR, VARARRAY[DX], CHGARRAY[DX]>
</CFLOOP>
<CFSET OUTSTR = 'print(" LX = ", LX, " LX2 = ", LX2, " RX = ", RX, " RX2 = ", RX2);'>
<CFOUTPUT>
#CODESTR# <br>
#OUTSTR#<br>
</CFOUTPUT>