IIRC, this only works if you want the same string for both matches.  I 
don't think that is what Andy wanted.

--Ben Doom

Barney Boisvert wrote:
> Yeah, you can do that.  Here's a simple example of it in action (using
> the backreference to match quotes). It also uses a non-greedy modifier
> in there to avoid doing an incorrect match on the apostrophe within
> the double quotes.
> 
> cheers,
> barneyb
> 
> <cfoutput>
> <cfset baseString = "some 'text' with ""quotes an' some apostrophes"" in it" 
> />
> <h2>Quoted Strings within #baseString#</h2>
> <ul>
> <cfset start = 1 />
> <cfloop condition="true">
>       <cfset result = REFind("(['""])(.*?)\1", baseString, start, true) />
>       <cfif result.pos[1] LT 1>
>               <cfbreak />
>       </cfif>
>       <cfset string = mid(baseString, result.pos[3], result.len[3]) />
>       <cfset quote = mid(baseString, result.pos[2], result.len[2]) />
>       <cfset start = result.pos[1] + result.len[1] />
>       <li>#string# (quoted with #quote#)</li>
> </cfloop>
> </ul>
> </cfoutput>
> 
> 
> On Nov 8, 2007 2:16 PM, Andy Matthews <[EMAIL PROTECTED]> wrote:
>> Adam Howitt wrote a blog post asking for improvements to a regex that he
>> wrote:
>> http://tinyurl.com/yvzxjk
>>
>> This is what I came up with:
>> \(-?[\w,.]+/-?[\w,.]+\)
>>
>> But I'm wondering if it's possible to reuse the first portion of the
>> expression, rather than writing the same exact thing twice in one string. So
>> rather than this:
>>
>> \(-?[\w,.]+/-?[\w,.]+\)
>>
>> I could have this:
>>
>> \((-?[\w,.]+)/\1\)
>>
>> or something like that. I could swear that I've seen someone do this before.
>> ____________________________________
>>
>> Andy Matthews
> 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:293037
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to