This will work...

/\[.*?\]/

The ".*?" means "match any character any number of times... BUT be
non-greedy about it".  The "?" is what makes it non-greedy, and that means
it will attempt to match as few characters as possible.  ...So in essence
this says "match an open bracket up to the first closing bracket".  Without
the "?" it would say "match an open bracket up to the *last* closing
bracket".

Probably more explaination than you wanted, but I felt like sharing :)

Rob 

-----Original Message-----
From: Akens, Anthony [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 25, 2002 9:50 AM
To: [EMAIL PROTECTED]
Subject: Pattern Matching


I'm trying to find a way to match anything between two brackets [....]  The
stuff in
between will have alpha, numeric, and symbols (including /  -  @ and spaces)

For instance

[akens@egh-org blah/blah/blah]

I need to match that entire string, including the []'s

Here's the ugly thing I've gotten so far to do it.  But I know there's a way
to simplify
it and just match anything between the []'s.  Thanks for any advice.

\[[A-Za-z'-@]* \S+[A-Za-z'/]\]


Tony Akens

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to