Skip to main content
Ben Nadel at Scotch On The Rock (SOTR) 2010 (London) with: Kevin Roche and Seb Duggan
Ben Nadel at Scotch On The Rock (SOTR) 2010 (London) with: Kevin Roche@kroche ) and Seb Duggan@sebduggan )

Adding New Regular Expression Parsing To My JRegEx Project For ColdFusion

By on
Tags:

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!

Oops!
NEW: Some basic markdown formatting is now supported: bold, italic, blockquotes, lists, fenced code-blocks. Read more about markdown syntax »
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.