> -----Original Message-----
> Message: 1
> Date: Tue, 08 May 2001 10:04:26 -0700
> From: "North, Wesley J" <[EMAIL PROTECTED]>
> Subject: Another stripping question
> To: "'[EMAIL PROTECTED]'"
> <[EMAIL PROTECTED]>
>
> Hello all,
>
> Quick question. I have the following variables:
>
> $ver_num1 = "3.2.1";
> $ver_num2 = "4.4";
> $ver_num3 = "4.0.1";
>
> I need to keep the first 2 numbers and discard the rest so that each
> variable will look like:
>
> $ver_num1 = 3.2
> $ver_num2 = 4.4
> $ver_num3 = 4.0
>
> From there I will strip out the ".", which is really easy. My
> question is,
> how do I strip everything except the first 2 numbers? Any/all
> suggestions
> will be greatly appreciated. Thanks much.
>
>
> -Wes
Well you could do something like this:
/(\d+)\D+(\d+)/;
Which would put the first two digits it encountered into the special
variables $1 and $2 so that in your examples you would have:
ver_num1 -> $1=3, $2=2
ver_num2 -> $1=4, $2=4
ver_num3 -> $1=4, $2=0
And there would be no need for you to strip out the decimal later.
Scott Johnson
_________________________________________________________________
C I S C O S Y S T E M S
Engineering Release Management
ISM Group
Champaign, Illinois
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl