* This one time, at band camp, Jobst Schmalenbach said:
> On Tue, Sep 18, 2001 at 04:43:06PM +1000, Mikolaj J. Habryn 
>([EMAIL PROTECTED]) wrote:
> > On Tue, Sep 18, 2001 at 04:30:30PM +1000, Jobst Schmalenbach wrote:
> > >  ".*@.*"
> > > I want to match only the last quoted string eg ".*@.*
> > > where the " is the last before the @
> > 
> >   "[^"]*@[^"]*"
> 
> You win :-))
> 
> Could you explain? I did some reading (I have Jeffrey Friedl's RegExp book)
> but dont understand how your regexp works.
> 

It works - but its not precise.  It is saying

Match "                                                                 : "
Match anynumber of chars that are not " : [^"]*
Match @                                                                 : @
Match anynumber of chars that are not " : [^"]*
Match "                                                                 : "

By any number - I also mean 0 - hence one of the problems...


,"[\w\d._]+@[\w\d.\-]+"$

is a more precise (though by no means complete) solution for your
current issue (tested with perl but the theory is sound)


Match a comma then double quote                                                 : ,"
Match any number (but at least 1) letter, word, . or _  : [\w\d._]+
Match @                                                                                
                 : @
Match any number (but at least 1) letter, word, . or -  : [\w\d.\-]+
Match " followed by end of line                                                 : "$

As you can see - you can adapt this one to allow more things (or
disallow them).  Matching valid email addresses is not an easy task for
a single regex.

HTH

Greeno
-- 
Greeno <[EMAIL PROTECTED]>
GnuPG Key :  1024D/B5657C8B 
Key fingerprint = 9ED8 59CC C161 B857 462E  51E6 7DFB 465B B565 7C8B

Imagine working in a secure environment and finding the string 
_NSAKEY in the OS binaries without a good explanation
    -Alan Cox 04/05/2001

-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to