or
even. . .
$string = "sct-1.62-1";
print "$1\n" if ($string =~ /^.+-(.+)-.+$/);
print "$1\n" if ($string =~ /^.+-(.+)-.+$/);
(no
need to use the backslash escape for the dashes; they're not part of a character
class. . .
GTO Application Development |
Keefe, Bruyette & Woods, Inc. |
212-887-6753 |
-----Original Message-----
From: Peter Eisengrein [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 11, 2004 2:52 PM
To: 'Cai, Lixin (L.)'; [EMAIL PROTECTED]
Subject: RE: A regular _expression_ questionYour format does not match XXX-XXX-XXX so I'll guess you mean three fields delimited by a dash.#### here's one way to do it$string = "sct-1.62-1";print "$1\n" if ($string =~ /^.+\-(.+)\-.+$/)-----Original Message-----
From: Cai, Lixin (L.) [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 11, 2004 2:37 PM
To: [EMAIL PROTECTED]
Subject: A regular _expression_ questionNow I have a string like
My $string = "sct-1.62-1";
I have 2 regular _expression_ question here,
A. I want to check whether the format is "XXX-XXX-XXX", how can I do it?
B. I want to get 1.62 from the string, how can I do it?Thanks a lot in advance!
Lixin
Lixin Cai
Security Compliance Tools(SCT)
Location: ITek 2WC135
Phone:313-317-4906
email: [EMAIL PROTECTED]
_______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs