On Thu, 2004-05-20 at 21:22, Rich Fernandez wrote: > I'm unclear about how alternation works in a regex. > > Say I want to find either "foo" or "bar" within a string. I don't care which > one I match, only that I make a match. > Would this be correct: /foo|bar/ > > Should they be grouped thusly: /(foo|bar)/ > > What about /(?:foo|bar)/ ? > > Specifically, I know that the second one remembers which one is found and > the third one doesn't. But is the first example wrong?
The first one also remembers what is found. It's the variable $& > TIA > > richf -- Josà Alves de Castro <[EMAIL PROTECTED]> Telbit - Tecnologias de InformaÃÃo -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>