Yes, it's the greedy match that's getting you -- I didn't think about that.
If you can classify the char that preceeds the email address (i.e. it's a
space or punctuation or either) then you can simply follow the .* with that
char or char class.  However, if the email can come at the beginning of the
string, you'll have a problem.

HTH.



  --Ben Doom
    Programmer & General Lackey
    Moonbow Software

: -----Original Message-----
: From: Lofback, Chris [mailto:[EMAIL PROTECTED]]
: Sent: Monday, December 23, 2002 2:05 PM
: To: CF-Talk
: Subject: RE: Regular expression question
:
:
: Hmm.  I like this more-concise method, but I only get the last
: character of
: the user ID rather than the full user ID.  For example, I use this...
:
: REReplace(Target,".*(['_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-
: z0-9-]+)*\
: (([a-z]{2,3})|(aero|coop|info|museum|name))).*", "\1")
:
: ..on "[EMAIL PROTECTED]" and I get "[EMAIL PROTECTED]".  Obviously, I'm rusty with RegEx
: but I seem to recall something about "greedy" RegEx pattern matching.  Is
: this maybe the cause?
:
: Thanks,
: Chris Lofback
: Sr. Web Developer
:
: TRX Integration
: 28051 US 19 N., Ste. C
: Clearwater, FL  33761
: www.trxi.com
:
:
: > -----Original Message-----
: > From: Ben Doom [mailto:[EMAIL PROTECTED]]
: > Sent: Monday, December 23, 2002 12:44 PM
: > To: CF-Talk
: > Subject: RE: Regular expression question
: >
: >
: > Or, if you prefer to simply return the matched bit in string
: > form, you can
: > do what I do (being a perlish kinda guy):
: >
: > newstring = rereplace(string,
: > ".*(whatever(yes you can use internal groupings) blah).*", "\1");
: >
: > Probably a lot less efficient than Ray's refind, but to my
: > mind it makes a
: > lot more sense.
: >
: > As always with RE questions:
: > http://www.houseoffusion.com/cf_lists/index.cfm?method=threads
: > &forumid=21
: > Read, Post to, or Join the list here for all your RegEx needs.  :-)
: >
: >
: >   --Ben Doom
: >     Programmer & General Lackey
: >     Moonbow Software
: >
: > : -----Original Message-----
: > : From: Raymond Camden [mailto:[EMAIL PROTECTED]]
: > : Sent: Monday, December 23, 2002 11:29 AM
: > : To: CF-Talk
: > : Subject: RE: Regular expression question
: > :
: > :
: > : Add the 3rd and 4th optional args - the 3rd arg, where to
: > start, should
: > : be set to 1, and the 4th, is a boolean that specifies if
: > you want the
: > : matched expressions returned. You will get a struct of two
: > arrays, pos
: > : and len, where pos[x] and len[x] is the position and length
: > of the Xth
: > : matched subexpression.
: > :
: > :
: > ==============================================================
: > =========
: > : Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
: > :
: > : Email    : [EMAIL PROTECTED]
: > : WWW      : www.camdenfamily.com/morpheus
: > : Yahoo IM : morpheus
: > :
: > : "My ally is the Force, and a powerful ally it is." - Yoda
: > :
: > : > -----Original Message-----
: > : > From: Lofback, Chris [mailto:[EMAIL PROTECTED]]
: > : > Sent: Monday, December 23, 2002 10:22 AM
: > : > To: CF-Talk
: > : > Subject: Regular expression question
: > : >
: > : >
: > : > Is there a way to return just the string that a REFind
: > : > matches?  I'm trying to pull an email address out of a block
: > : > of text.  I can find the beginning using this:
: > : >
: > : > REFindNoCase("['_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-
: > : > 9-]+)*\.(([a-z
: > : > ]{2,3})|(aero|coop|info|museum|name))",BlockOfText)
: > : >
: > : > But I don't see how to match the end.  It seems like I need
: > : > to return the "\1" back reference, but how?
: > : >
: > : > Thanks,
: > : > Chris Lofback
: > : > Sr. Web Developer
: > : >
: > : > TRX Integration
: > : > 28051 US 19 N., Ste. C
: > : > Clearwater, FL  33761
: > : > www.trxi.com
: > : >
: > : >
: > :
: >
: 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to