> So \w means the first non word character. Oh, and BTW, \W would be the non-word match pattern, not \w.
Steve What about the ~ / before > the > (\w? And what does the + sign do? Is $buf a command? > > Thanks > > AD > > -----Original Message----- > From: Bob Showalter [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 19, 2004 8:57 AM > To: 'Khairul Azmi'; [EMAIL PROTECTED] > Subject: RE: simple regular expression problem > > Khairul Azmi wrote: >> Hi all, >> I am a newbie. I just need to extract the string containing the unix >> account from the following text >> >> <[EMAIL PROTECTED]> SIZE=1024. > > I'm guessing you want to extract the string "user"? (But how do you > know > that that corresponds to a Unix account?) > > The following will catpure "user" from the example you gave: > > ($acct) = $buf =~ /(\w+)/; > > This works because: > > a) \w matches 'u', 's', 'e', and 'r', but not '<' or '@' > b) regexes match the "longest, leftmost" sequence, so > 'user' matches instead of 'gmail'. > > You would be advised to replace \w with the actual class of characters > that > are allowed in user names... > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>