portal entry

select a category, or use search below
(searches all categories and all time range)
Title:

Regular expressions – practical examples to get you started

| View in Portal
June 09, 2019 11:28:36 AM GMT
3 Comments
<p>Regular expressions - practical examples to get you started</p>
<p>The post <a rel="nofollow" href="https://coldfusion.adobe.com/2019/06/regular-expressions-practical-examples-get-started/">Regular expressions – practical examples to get you started</a> appeared first on <a rel="nofollow" href="https://coldfusion.adobe.com">ColdFusion</a>.</p>
Labels: Blog, ColdFusion, Modern CFML, 2018, blog, modern cfml

Comments:

We've encountered some unpreventable ColdFusion hard errors (that can't be prevented using try/catch) when using ReReplaceNoCase() in our application framework.  Here are some reported bugs that are similar: <a href="https://tracker.adobe.com/#/view/CF-3928688" rel="nofollow">https://tracker.adobe.com/#/view/CF-3928688 </a><a href="https://tracker.adobe.com/#/view/CF-4165797" rel="nofollow">https://tracker.adobe.com/#/view/CF-4165797</a> To work around this intermittently occuring bug (which Adobe classifies as "UserError" or "AsDesigned"), we started casting the initial value as a string (required for Java; not all CF-typeless variables contain pure "string" values) and using Java's replaceAll().  Our functions now seem faster, but more importantly there's no occassional CFError occurring in any of our apps. When using regular expressions with ColdFusion, the ReEscape() function (available since CF10) simplifies escaping characters that match regular expression control characters. <a href="https://cfdocs.org/reescape" rel="nofollow">https://cfdocs.org/reescape</a> If interested in using more regex matching functions in ColdFusion, check out Ben Nadel's JRegEx: <a href="https://www.bennadel.com/blog/3322-jregex---a-coldfusion-wrapper-around-java-s-regular-expression-patterns.htm" rel="nofollow">https://www.bennadel.com/blog/3322-jregex---a-coldfusion-wrapper-around-java-s-regular-expression-patterns.htm</a>
Comment by James Moberg
2121 | June 12, 2019 01:34:01 PM GMT
We've encountered some unpreventable ColdFusion hard errors (that can't be prevented using try/catch) when using ReReplaceNoCase() in our application framework.  Here are some reported bugs that are similar: https://tracker.adobe.com/#/view/CF-3928688 https://tracker.adobe.com/#/view/CF-4165797 To work around this intermittently occuring bug (which Adobe classifies as "UserError" or "AsDesigned"), we started casting the initial value as a string (required for Java; not all CF-typeless variables contain pure "string" values) and using Java's replaceAll().  Our functions now seem faster, but more importantly there's no occassional CFError occurring in any of our apps. When using regular expressions with ColdFusion, the ReEscape() function (available since CF10) simplifies escaping characters that match regular expression control characters. https://cfdocs.org/reescape If interested in using more regex matching functions in ColdFusion, check out Ben Nadel's JRegEx: https://www.bennadel.com/blog/3322-jregex---a-coldfusion-wrapper-around-java-s-regular-expression-patterns.htm
Comment by James Moberg
2120 | June 12, 2019 02:44:04 PM GMT
Hi James, I'd not seen those tickets before. I tried them on ACF2016 / 2018 and seems to be OK (although you mentioned that it's intermittent so maybe I got lucky). <a href="https://cffiddle.org/app/file?filepath=21066788-3f1b-4755-9a0f-928b354f4ad9/db316ff9-ca2c-462b-b248-ae146a1fe667/43406745-de7d-4db4-94b6-66f5a27ed738.cfm" rel="nofollow">https://cffiddle.org/app/file?filepath=21066788-3f1b-4755-9a0f-928b354f4ad9/db316ff9-ca2c-462b-b248-ae146a1fe667/43406745-de7d-4db4-94b6-66f5a27ed738.cfm</a> I have dropped down to using Java regular expressions before as you can cache the patterns which can improve performance. There is also some extra functionality you get by using the Java, so would agree that it's worth a look (thanks for adding the links). This post was aimed at people who had never used regular expressions before, so tried to keep it clear and concise.
Comment by aliaspooryorik
2122 | June 13, 2019 08:02:46 PM GMT