Sorcerer's Tower

International Regular Expressions Day!

Today, 1st June 2008, has been officially decreed as Regular Expressions Day.

And in honour of this event, there are a couple of regex-oriented competitions happening.

Ben Nadel, nominator of this great day, kicked things off with a handful of prizes for the best comments: June 1st 2008 - National Regular Expression Day!

The deadline for Ben's competition is today - that is, you must post the comment on (or before) RegExp Day, and the winners will be selected tomorrow.

Don't despair if you miss that though, as Steve Levithan also has a regular expression competition running, and the deadline for that is Friday 13th, almost two weeks from now: Regex Day Contest

Happy RegEx Day!

QueryParam Scanner

The code for my QueryParam Scanner has been uploaded to RIAForge.

QueryParam Scanner is a simple tool which scans your code for queries and reports back about any variables that are not inside <cfqueryparam/> tags.

Download QueryParam Scanner from RIAForge.

Java RegEx Utilities

I have just released Java RegEx Utilities on RIAForge, which is a CFC enabling easy access to Java Regular Expression functionality, adding to what is available in the standard CFML functions.

Currently there are two main functions.

jre.get(Text,RegEx) returns the matches to the regular expression as an array.

jre.replace(Text,RegEx,Replacement) is similar to REReplace, but the Replacement argument can be a function pointer, allowing you to process the results of a regex match with a function

You can find more usage details on the jre-utils wiki, which I plan to update with some examples of when each of these functions can be useful.

I have tested jre-utils against Railo 2 and CFMX 7, but it should also work with ColdFusion 8 and the Java version of BlueDragon - if anyone can test/confirm this please let me know.

Download Java RegEx Utilities from RIAForge.

JavaScript Leap Year check

I've just needed to fix a calendar that didn't implement leap years, and thus was missing 29th Feb this year.

Unfortunately, Google was bringing up various functions that rely on how browsers handle oddities in the built-in date functions, which isn't a sensible approach.

So, here is how to do it relying on the leap year formula:

function isLeapYear(year)
{return ((year%4 == 0) && (year%100 != 0 || year%400 == 0));}

And to implement that:

function readDaysInMonth(month,year)
	if (month == 1 && isLeapYear(year) == true) return 29;
	else return [31,28,31,30,31,30,31,31,30,31,30,31][month];

(Remember, in JS months are 0-indexed, hence 1 = Feb)

Fusebox 5.5 is out now!

The highly anticapted next major version of Fusebox has finally been released to the website.

Fusebox 5.5 allows you to use the Fusebox applications without using XML, which should please many people.

Instead of fusebox.xml it checks conventional places for your circuits, and instead of circuit.xml it can either use CFCs, where each function is a fuseaction, or just a directory, where each file is a fuseaction.

It also brings support for dynamic do to both xml and non-xml configuration, which is a feature I've really wanted on a couple of occasions.

Get it while it's hot...