Thanks guys for all your help its been a good regex learning
experience as usual for me :)
@Ben yours is the one i've gone with thank for the comments and explanation
Andy J
On Nov 7, 2007 8:24 PM, Ben Doom <[EMAIL PROTECTED]> wrote:
> A handful of comments:
>
> Backreferencing a single, static character is silly. It just wastes
> memory and processor time. You're throwing it away, anyway.
>
> {1} is useless. It means "one of". Which would just be the thing by
> itself.
>
> Second, {1,} is more commonly written +. Also, you are saying "one or
> more backreferenced things" instead of "one or more backreferenced things.
>
> I'd write it like this:
> @([a-zA-Z0-9]+)
> Then use the first backreference instead of the second.
>
> --Ben Doom
>
>
> Andy Jarrett wrote:
> > Hi
> >
> > I'm trying to do a look through as string to find usernames and add
> > <a> tags around them ala Twitter.
> >
> > The regex I think is fine but when I use reReplace 's back reference
> > I'm not getting the result I thought I would of. Heres the code. Can
> > anyone see anything obvious?
> >
> > Cheers, Andy
> >
> >
> > <!--- String to be manipulated --->
> > <cfset str = "First username is @andrew and second is @jarrett" />
> > <cfoutput><p>#str#</p></cfoutput>
> >
> >
> > <!--- The Regex
> > (@){1} - First back reference is the @ sign. Look for one of these
> > ([a-zA-Z0-9]){1,} - Second back reference is the username
> > --->
> > <cfset reg = "(@){1}([a-zA-Z0-9]){1,}" />
> >
> > <!--- Using reReplace we take the second back reference and wrap
> > an <a> tag around it --->
> > <cfset usernamePos = reReplace(str, reg, "@<a href='test'>\2</a>", "all") >
> >
> > <cfoutput>#usernamePos#</cfoutput>
> >
> >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:293019
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4