TerrenceRyan.com

I'm a 35 year old redhead geek from Philly.
I'm currently a Developer Evangelist for Adobe.
Also the author of Driving Technical Change

ColdFusion String Manipulation

7 Comments

I don't know if this is new to everyone, but it was to me. Jason Delmore , the Product Manager for ColdFusion informed us of something intriguing in his Developing Hybrid Applications with ColdFusion and Java and talk today. He informed us that ColdFusion strings are an extension of the Java String class. Which means that methods of Java strings are available to ColdFusion. What does this mean? It means that this is valid code:

<cfset test_1= "A string to test" />
<cfset test_2= "A string to add on to a string to test." />
<cfset test_1 = test_1.concat(test_2) />

Not only is it more elegant of other ColdFusion string concatenation techniques, it appears to run about twice as fast.

Also any other method listed in the Java String reference will work.

7 responses so far ↓

  • 1 Ben Nadel

    Yeah that is cool. Also, perhaps my favorite Java string method for use in ColdFusion is ReplaceAll() and ReplaceFirst(). These use regular expressions and are much faster than the CF equivalents.
  • 2 JAlpino

    Don't forget about StringBuffers, they perform very well especially when building large strings.
  • 3 Terrence Ryan

    I haven't compared this method to StringBuffers yet. So much to try, so little time.
  • 4 Mark Mandel

    I've always liked the string method .startsWith() much easier to use.

    Let's not also forget -

    Parsed Dates are java.util.Date
    Arrays are java.util.Vector
    Structs are java.util.Hashmap
    Query results are java.sql.ResultSet

    there are lots and lots out there ;o)
  • 5 Brandon Harper

    Yes, JAlpino is correct. If you need to do much string manipulation, use StringBuffers. Strings in Java are immutable objects, so at least one new object must be created when you "change" a String.
  • 6 Terrence Ryan

    I subtly diagree with you, Brandon. I would say if you have to <strong>optimize</strong> string manipulation, use StringBuffers.
  • 7 funny jokes man

    Great! I only recently started using Cold Fusion, and was just doing some research on it. It's good to know that ReplaceAll(); will work.

Leave a Comment









Categories

Monthly Archives

Tag Cloud

coldfusion web development flex coldfusion builder appearances squidhead coldfusion builder extensions higher ed flash builder air mobile android adobe apptacular html5 driving technical change running a coldfusion shop adobemax06 movable type flash catalyst flash blackberry adobemax07 adobemax08 hero finicky css adobemax09 holy crap i’m a mobile developer centaur basecamp cfc unfuddle motorola metablog irrational characters ios git evangelism devices code reviews ant wharton subversion security phonegap philly philadelphia multidevice knowledge@wharton jobs browserlab adobemax10 adobe tv unfuddlecfc svnauth.cfc semantic html semantic html responsive web design qnx nlb linux jquery mobile java it github flexorg fireworks edge eclipse dreamweaver apps apple adobemax11