-----Original Message----- From: bob ackerman [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 28, 2002 11:32 AM To: richard noel fell Cc: [EMAIL PROTECTED] Subject: Re: pattern matching question
On Thursday, February 28, 2002, at 08:37 AM, richard noel fell wrote: > while (defined($Line=<In2>)){ > if($Line=~/(\(D\d+\))\s*(\w*)/){ > print "==> $2\n"; > }; > }; > disclaimer: i am a rank newbot if i replace '/w*' with '.*$' i get desired text. looks like \w* doesn't do what we expect. problems with \t in lines? -------------------------- I'm also new to Perl, so I won't correct your typo, but I will point out a problem in your statement: "looks like \w* doesn't do what we expect." I'm not sure who "we" is, but this does exactly what is expected. '\w*' matches zero or more word characters. The problem with the match is that the white space in the lines was followed by non-word characters ('-' and '/'). A word character is any letter, number, or underscore. Your match with '.*' works because that matches zero or more of ANY character. As for the question: "problems with \t in lines?", that should not make any difference to the match, because '\s*' would match the tabs, as tabs are considered whitespace characters. HTH! Jason CONFIDENTIALITY NOTICE: ************************************************************************ The information contained in this ELECTRONIC MAIL transmission is confidential. It may also be privileged work product or proprietary information. This information is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution [other than to the addressee(s)], copying or taking of any action because of this information is strictly prohibited. ************************************************************************