Using RegEx and Java to Split a String in Coldfusion

I was looking for a great way to split a string using a regex expression. Ben Nadel had a good post where he’s creating an RESplit() method. This was a little more than I wanted to go into, and after some more searching I found the solution was to use Java (usually is the solution ;-) as shown by Raymond Camden. So without further discussion, here’s what you need:

// Splitting a query column value by linefeeds
// You could just as easily do this with any RegEx
ItemsArray = myQuery.Notes[1].split( chr(13) );

One thought on “Using RegEx and Java to Split a String in Coldfusion

  1. Awesome! I did not know about /u. I have been trying (unsuccessfully) to get ctype_alpha to work with acncteed characters. You learn something new every day A little typo, however. preg_match($pattern, $string, $matches); should be preg_match($pattern, $input, $matches); And that greater than sign is getting htmlentiti-fied.

Leave a Reply to Trisha Cancel reply

Your email address will not be published. Required fields are marked *