[Nottingham] Perl Regular Expression Query.

Simon Amor nottingham at mailman.lug.org.uk
Fri Jan 17 20:59:01 2003


Martin Garton wrote:
> On Fri, 17 Jan 2003, Robert Postill wrote:
> 
> > /@.*?@.*?@.*?@/
> 
> I think using just /@.*@.*@.*@/ will work.
> You dont need the question marks, since * means match the preceeding
> expression zero or more times anyway. (Note: I havent tried it!)

The ? after the .* means don't do a greedy match.

eg a@b@c@d@e@f@g@h@j@ might match the regex too but what is the first @
in the regex going to match?

If you're trying to use the actual values between the @, you will need
() around each .*? and then $1,$2,$3 etc will be set.

  Simon
-- 
Simon Amor   simon@shoe.bocks.com    
ICQ:529466   http://shoe.bocks.com/
             GPG/PGP key: 0xF318D5F3