Adding New Regular Expression Parsing To My JRegEx Project For ColdFusion
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 )
:: StringjreAfterLast( targetText, patternText )
:: StringjreBefore( targetText, patternText )
:: StringjreBeforeLast( targetText, patternText )
:: StringjreEndingWith( targetText, patternText )
:: StringjreEndsWith( targetText, patternText )
:: BooleanjreStartingWith( targetText, patternText )
:: StringjreStartsWith( targetText, patternText )
:: Boolean
JRegExList.cfc
(entirely new ColdFusion component)
jreListFirst( list, delimiterPattern [, includeEmptyFields] )
:: StringjreListGetAt( list, position, delimiterPattern [, includeEmptyFields] )
:: StringjreListLast( list, delimiterPattern [, includeEmptyFields] )
:: StringjreListLen( list, delimiterPattern [, includeEmptyFields] )
:: NumberjreListMap( list, callback, delimiterPattern [, includeEmptyFields] )
:: StringjreListRest( list, delimiterPattern [, includeEmptyFields] )
:: StringjreListSetAt( list, position, value, delimiterPattern [, includeEmptyFields] )
:: StringjreListToArray( list, delimiterPattern [, includeEmptyFields] )
:: ArrayjreSegment( 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 →