In some cases, you might want to find a repeating pattern of characters in a search string. For example, the regular expression "a{2,4}" specifies to match two to four occurrences of "a". Therefore, it would match: "aa", "aaa", "aaaa", but not "a" or "aaaaa". In the following example, the REFind
function returns an index of 6:
<cfset IndexOfOccurrence=REFind("a{2,4}", "hahahaaahaaaahaaaaahhh")> <!--- The value of IndexOfOccurrence is 6--->
The regular expression "[0-9]{3,}" specifies to match any integer number containing three or more digits: "123", "45678", etc. However, this regular expression does not match a one-digit or two-digit number.
You use the following syntax to find repeating characters:
{
m,n}
Where m is 0 or greater and n is greater than or equal to m. Match m through n (inclusive) occurrences.
The expression {0,1} is equivalent to the special character ?.
{
m,}
Where m is 0 or greater. Match at least m occurrences. The syntax {,
n}
is not allowed.
The expression {1,} is equivalent to the special character +, and {0,} is equivalent to *.
{
m
}
Where m is 0 or greater. Match exactly m occurrences.