However, sometimes you might want to override this default behavior to find the shortest string
that matches the regular expression. ColdFusion includes minimal-matching quantifiers that let
you specify to match on the smallest string. The following table describes these expressions:
Expression
*?
+?
??
{min,}?
{min,max}?
{n}?
If you modify the previous example to use the minimal-matching syntax, the code is as follows:
<cfset sLenPos=REFind("<b>(.*?)</b>", "<b>one</b> <b>two</b>", 1, "True")>
<cfoutput>
<cfdump var="#sLenPos#">
</cfoutput><br>
The following figure shows the output of the
Thus, the length of the string found by the regular expression is 10, corresponding to the string
"<b>one</b>".
Regular expression examples
The following examples show some regular expressions and describe what they match:
Expression
[\?&]value=
[A-Z]:(\\[A-Z0-9_]+)+
[A-Za-z][A-Za-z0-9_]*
([A-Za-z][A-Za-z0-9_]*)(\.[A-Za-z]
[A-Za-z0-9_]*)?
(\+|-)?[1-9][0-9]*
(\+|-)?[1-9][0-9]*(\.[0-9]*)?
158
Chapter 7: Using Regular Expressions in Functions
Description
minimal-matching version of *
minimal-matching version of +
minimal-matching version of ?
minimal-matching version of {min,}
minimal-matching version of {min,max}
(no different from {n}, supported for notational consistency)
Description
A URL parameter value in a URL.
An uppercase DOS/Windows path in which (a) is not the
root of a drive, and (b) has only letters, numbers, and
underscores in its text.
A ColdFusion variable with no qualifier.
A ColdFusion variable with no more than one qualifier; for
example, Form.VarName, but not Form.Image.VarName.
An integer that does not begin with a zero and has an
optional sign.
A real number.
tag:
cfdump
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers