The example I showed was just an example, really the telephone number could be anything

+31 07 3433 3243
07 3433 2111
4345 3434
33334455


-----Original Message-----
From: Matthew Walker [mailto:[EMAIL PROTECTED]
Sent: Thursday, 20 November 2003 10:25 AM
To: CFAussie Mailing List
Subject: [cfaussie] Re: RegEx Backreferences...


> It's so that I know pos[3] will always return the area code.

But the area code is the first subexpression starting at pos[2] . . . ?

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:bounce-cfaussie-
> [EMAIL PROTECTED] On Behalf Of Taco Fleur
> Sent: Thursday, 20 November 2003 11:56 a.m.
> To: CFAussie Mailing List
> Subject: [cfaussie] Re: RegEx Backreferences...
> 
> ok next one...
> 
> Can you do something like
> 
> (\+\d+|select nothing here, but populate structure)
> 
> Reason for doing this is so that
> pos[2] len[2] will exists, if that makes any sense?
> 
> It's so that I know pos[3] will always return the area code.
> 
> -----Original Message-----
> From: Spike [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 20 November 2003 9:41 AM
> To: CFAussie Mailing List
> Subject: [cfaussie] Re: RegEx Backreferences...
> 
> 
> Something like this should do it for you:
> 
> <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 leave-cfaussie-
> [EMAIL PROTECTED]
> 
> MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
> http://www.mxdu.com/ + 24-25 February, 2004
> 
> ---
> You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to leave-cfaussie-
> [EMAIL PROTECTED]
> 
> MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
> http://www.mxdu.com/ + 24-25 February, 2004




---
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

---
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

Reply via email to