Duncan's blog

August 21, 2013

Regexes for ColdFusion function output attribute

Filed under: Coldfusion,Regular Expressions — duncan @ 5:37 pm
Tags: , ,

One of the things that I frequently see ColdFusion developers forgetting about or getting wrong is the output attribute on cffunction.

Either it’s completely omitted, in which case it’s the same as adding output=true (and will result in extra whitespace being output).

Or it’s incorrectly set to true.  I think developers sometimes assume that if they’re doing something like looping over a query using <cfoutput query=”…”> then they need to have the output set to true.

Here’s a couple of handy regular expressions I sometimes use to find when this has happened.  This blog article is more for my own future reference than anything else.

First (this is from Brian Ghidinelli), this one finds functions without the output attribute:


Secondly, this finds those where it’s not set as false or no.


The (?! … ) syntax is a negative lookahead.  Basically we’re saying, get me everywhere we have something that looks like cffunction output = (not ‘false’ or ‘no’)

This is assuming your text editor can do negative lookaheads.  Alternatively it’s probably simpler to do that the other way round and get everywhere it is cffunction output = (‘true’ or ‘yes’)


1 Comment »

  1. A quicker, easier fix is to enable white space management in CF administrator

    Comment by Scott Stroz — August 21, 2013 @ 11:51 pm | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: