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

-- 
Barney Boisvert
[EMAIL PROTECTED]
http://www.barneyb.com/

Got Gmail? I have 100 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get involved in the latest ColdFusion discussions, product
development sharing, and articles on the Adobe Labs wiki.
http://labs/adobe.com/wiki/index.php/ColdFusion_8

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:293009
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