Well, that's what I finally arrived at anyway :) But that's a whole 15
minutes of my time wasted :( However, CF makes up for quite a lot of that
lost time that I would've otherwise wasted in PHP.

Anyway. I guess character transformations can be done outside CF in Java and
then linked to CF. But I'm _not_ going to do that right now. So, I'm stuck
with an XML-based solution right now (not that I'm complaining or anything,
I just hate XML :) )

On 8/16/06, Everett, Al (NIH/NIGMS) [C] <[EMAIL PROTECTED]> wrote:
>
> Couldn't a UDF get close to that?
>
> <cffunction name="REReplaceByArray" returntype="string">
>         <cfargument name="patternArray" type="array" required="yes">
>         <cfargument name="replacementArray" type="array" required="yes">
>         <cfargument name="stringValue" type="string" required="yes">
>
>         <cfset var i=0>
>         <cfset var returnString="">
>
>         <cfif arrayLen(arguments.patternArray) neq arrayLen(
> arguments.replacementArray)>
>                 <cfthrow message="patternArray and replacementArray are
> not the same size.">
>         </cfif>
>
>         <cfset returnString=arguments.stringValue>
>
>         <cfloop from="1" to="#arrayLen(arguments.patternArray)#"
> index="i">
>                 <cfset
> returnString=REReplace(returnString,patternArray[i],replacementArray[i],"all")>
>         </cfloop>
>
>         <cfreturn returnString>
> </cffunction>
>
> <cfset myString="The quick brown fox jumped over the lazy dog.">
>
> <cfset patterns=arrayNew(1)>
> <cfset patterns[1] = "quick">
> <cfset patterns[2] = "brown">
> <cfset patterns[3] = "fox">
>
> <cfset replacements=arrayNew(1)>
> <cfset replacements[3] = "bear">
> <cfset replacements[2] = "black">
> <cfset replacements[1] = "slow">
>
> <cfoutput>#REReplaceByArray(patterns,replacements,myString)#</cfoutput>
>
>
> Needs a bit of tweaking, but...
>
> -----Original Message-----
> From: Dmitrii Dimandt [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 16, 2006 12:08 PM
> To: CF-Talk
> Subject: Re: Transform Unicode characters
>
> Accepts arrays for both patterns and replacements. From the docs:
>
> <?php
> $string = 'The quick brown fox jumped over the lazy dog.';
>
> $patterns[0] = '/quick/';
> $patterns[1] = '/brown/';
> $patterns[2] = '/fox/';
>
> $replacements[2] = 'bear';
> $replacements[1] = 'black';
> $replacements[0] = 'slow';
>
> echo preg_replace($patterns, $replacements, $string); ?>
>
> But anyway, problem solved... In a way...
>
> On 8/16/06, Everett, Al (NIH/NIGMS) [C] <[EMAIL PROTECTED]> wrote:
> >
> > What does preg_replace do that REReplace() doesn't?
> >
> > -----Original Message-----
> > From: Dmitrii Dimandt [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, August 16, 2006 11:04 AM
> > To: CF-Talk
> > Subject: Re: Transform Unicode characters
> >
> > Because it transforms charactrs into garbage (sth. like %C4%B1 for ý).
> > And I need human-readable format :)) Anyway. I guess I'll stick to my
> > XML solution. I read mappings from a UTF-8 encoded XML file into
> > arrays and then iterate over them and replace whatever characters I
> > need. I miss PHP's preg_replace :)))
> >
> >
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250122
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to