Thanks a lot for your email. It helps me solve the problem. Have a nice day! Lixin
-----Original Message----- From: Thomas_M [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 12, 2002 3:47 PM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: A regular expression question Cai_lixin wrote: > I want to get the comment after # of each line(not including > "#"), how could I do this? Depends. If you might have a # in a command, you'll want everything after the last #. If you're more likely to have another # in a comment, you want everything after the first #. (if you wanted to handle the situation where there could be an embedded # in both the command and the comment, then it gets a little more complicated) For last #: $comment = (split /#/, $line)[-1]; or ($comment = $line) =~ s/^.*#//; For first #: $comment = (split /#/, $line, 2)[1]; or ($comment) = $line =~ s/^[^#]*#//; Notes: Be sure to chomp() the line if you don't want the newline. There are also ways to do this that do not involve regexps. -- Mark Thomas [EMAIL PROTECTED] Internet Systems Architect User Technology Associates, Inc. $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
