Skip to main content
Ben Nadel at cf.Objective() 2010 (Minneapolis, MN) with: Doug Hughes and Ezra Parker and Dan Wilson and John Mason and Jason Dean and Luis Majano and Mark Mandel and Brian Kotek and Wil Genovese and Rob Brooks-Bilson and Andy Matthews and Simeon Bateman and Ray Camden and Chris Rockett and Joe Bernard and Dan Skaggs and Byron Raines and Barney Boisvert and Simon Free and Steve 'Cutter' Blades and Seth Bienek and Katie Bienek and Jeff Coughlin
Ben Nadel at cf.Objective() 2010 (Minneapolis, MN) with: Doug Hughes Ezra Parker Dan Wilson John Mason Jason Dean Luis Majano Mark Mandel Brian Kotek Wil Genovese Rob Brooks-Bilson Andy Matthews Simeon Bateman Ray Camden Chris Rockett Joe Bernard Dan Skaggs Byron Raines Barney Boisvert Simon Free Steve 'Cutter' Blades Seth Bienek Katie Bienek Jeff Coughlin

Adding New Regular Expression Parsing To My JRegEx Project For ColdFusion

By
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

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
Managed hosting services provided by:
xByte Cloud Logo