<cfset regex = "(\d+)\s+(\d{4}\s+\d{4})">
<cfset str = "07 1234 5678"><cfset stResult = reFindNoCase(regex,str,1,true)>
<cfdump var="#stResult#">
<cfset areacode = mid(str,stResult.pos[2],stResult.len[2])> <cfset number = mid(str,stResult.pos[3],stResult.len[3])>
<cfoutput>(#areacode#) #number#</cfoutput>
If you return sub-expressions, the resulting structure will contain multiple entries. The first element in the pos and len arrays will be the match for the whole regex. The subsequent entries will be the matches for the sub-expressions.
There should be n+1 entries in those arrays. Where n is the number of sub-expressions in your regex.
Spike
Taco Fleur wrote:
Morning!
How do I return back references? (maybe I need another coffee, but I just don't see it)
The regex (\d+)\s+(\d{4}\s+\d{4})
07 1234 5678
I know I can reference to the area code by 07 = \1 I know I can reference to the telephone number by 1234 5678 = \2
But how in godsname do I output it?
I could NOT just do <cfoutput> #\1# #\2# </cfoutput>
All I can think of is using reReplace() but surely there must be some other way!?
*Taco Fleur 07 3535 5072* Tell me and I will forget Show me and I will remember Teach me and I will learn
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004
-- Stephen Milligan Software Architect for http://www.bestrates.com.au MSN: [EMAIL PROTECTED]
--- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia http://www.mxdu.com/ + 24-25 February, 2004
