This is a minor but important fact that I just realized. ColdFusion's CFParam tag regular expression validation tests its pattern on the entire value in question. This means that you don't have to worry about partial string matches. What this means is that you never need to use the start (^) and end ($) delimiters as these are applied implicitly. So, for example, the CFParam tag:
<cfparam name="name" type="regex" pattern="naomi" />
... is really implicitly applying the pattern:
This is good to know, as I had previously been using the start and end line delimiters. But, this also lead to a new realization - pattern flags don't have to be the very first thing in a regular expression pattern. These patterns are case-sensitive, so you if you wanted to make it case-insensitive, you would have to add the "i" flag:
<cfparam name="name" type="regex" pattern="(?i)naomi" />
Of course, this is actually applying the pattern:
I used to think that the pattern flags (?i) had to be the very first thing in the pattern, but apparently not (and the RegEx Coach confirms this as well).
So again, this is really minor, but an important point to understand.
Want to use code from this post? Check out the license.