Skip to main content
Ben Nadel at CFUNITED 2009 (Lansdowne, VA) with: Gail "Montreal" Shoffey Keeler
Ben Nadel at CFUNITED 2009 (Lansdowne, VA) with: Gail "Montreal" Shoffey Keeler

Adding New Regular Expression Parsing To My JRegEx Project For ColdFusion

Published in

As part of the recent Regular Expression Day celebrations, I was working on some fun and exciting ways to parse strings and lists using RegEx patterns in ColdFusion. As a quick follow-up to those joyous outbursts, I've gone and added those new methods to my JRegEx ColdFusion component. In fact, I've added a new JRegExList.cfc component to this project for list-specific parsing - I didn't want to mix the two genres together.

View this code in my JRegEx project on GitHub.

Here's a breakdown of the new methods that I added:

JRegEx.cfc (existing ColdFusion component)

  • jreAfter( targetText, patternText ) :: String
  • jreAfterLast( targetText, patternText ) :: String
  • jreBefore( targetText, patternText ) :: String
  • jreBeforeLast( targetText, patternText ) :: String
  • jreEndingWith( targetText, patternText ) :: String
  • jreEndsWith( targetText, patternText ) :: Boolean
  • jreStartingWith( targetText, patternText ) :: String
  • jreStartsWith( targetText, patternText ) :: Boolean

JRegExList.cfc (entirely new ColdFusion component)

  • jreListFirst( list, delimiterPattern [, includeEmptyFields] ) :: String
  • jreListGetAt( list, position, delimiterPattern [, includeEmptyFields] ) :: String
  • jreListLast( list, delimiterPattern [, includeEmptyFields] ) :: String
  • jreListLen( list, delimiterPattern [, includeEmptyFields] ) :: Number
  • jreListMap( list, callback, delimiterPattern [, includeEmptyFields] ) :: String
  • jreListRest( list, delimiterPattern [, includeEmptyFields] ) :: String
  • jreListSetAt( list, position, value, delimiterPattern [, includeEmptyFields] ) :: String
  • jreListToArray( list, delimiterPattern [, includeEmptyFields] ) :: Array
  • jreSegment( list, delimiterPattern ) :: Array

After looking at this list, I might remove the List prefix on the methods. Since they are already part of a ColdFusion component that has List in the name, I'm not sure we need the redundancy in the method names as well.

NOTE: The jre prefix on all the method names is to avoid any collision with built-in ColdFusion functions.

Keep on parsing, my friends!

Reader Comments

Post A Comment — I'd Love To Hear From You!

Post a Comment

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel