I have the following php code which I need to convert into coldfusion...
preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $code,
$varrefs);
$varcount = sizeof($varrefs[1]);
for ($i = 0; $i < $varcount; $i++)
{
$namespace = $varrefs[1][$i];
$varname = $varrefs[3][$i];
$new = $this->generate_block_varref($namespace, $varname);
$code = str_replace($varrefs[0][$i], $new, $code);
}
I've used the reGet udf off cflib and ive got it to:
<cfset varrefs =
reGet(code,'\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}')>
<cfloop to="#ArrayLen(varrefs)#" index="i" from="1">
<cfset namespace =
ReReplace(varrefs[i],'\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}','\1')>
<cfset varname =
ReReplace(varrefs[i],'\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}','\3')>
<cfset new = generate_block_varref(namespace,varname)>
<cfset code = Replace(code,varrefs[i],new,"ALL")>
</cfloop>
It supposed to take variables within a template such as {T_FONT_COLOR} and
replace them with a value, but it doesnąt seem to be picking them up right.
Im thinking its a problem with the regex, but I'm not too hot on them... Can
somebody point me in the right direction??
Ryan
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]