REMatchGroups() ColdFusion User Defined Function

<!--- Loop over the phone numbers. --->
<cfloop
	index="intI"
	from="1"
	to="#ArrayLen( arrMatches )#"
	step="1">
 
	<!--- Get the groups. --->
	<cfset objGroups = arrMatches[ intI ] />
 
	<p>
		(#objGroups[ 1 ]#) #objGroups[ 2 ]#-#objGroups[ 3 ]#
 
		<!--- Check to see if a phone ext. was found. --->
		<cfif StructKeyExists( objGroups, "4" )>
			x#objGroups[ 4 ]#
		</cfif>
	</p>
 
</cfloop>

For Cut-and-Paste