Actually, since the others are numbers you could replace the last two \S+
with \d+
----- Original Message -----
From: "Tanton Gibbs" <[EMAIL PROTECTED]>
To: "Michael Stearman" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, April 02, 2002 12:06 PM
Subject: Re: Creating variables of a string


> my ($word, $num1, $num2) = $string =~ /^\s*(\S+)\s+(\S+)\s+(\S+)\s*$/;
>
> This matches
> ^ - the start of the string
> \s* - any number (including 0) of spaces
> (\S+) - any number (not including 0) of NON spaces.  It also saves the
value
> \s+ - any number (not including 0) of spaces
> (\S+) - see above
> \s+ - see above
> (\S+) - see above
> \s* - see above
> $ - the end of the string (including a possible newline)
>
> The saved values will then be set back to the three variables $word,
$num1,
> and $num2
> ----- Original Message -----
> From: "Michael Stearman" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, April 02, 2002 12:02 PM
> Subject: Creating variables of a string
>
>
> >
> > Hi,
> >
> > I have a string that contains a word and 2 numbers.  For example,
> >
> > Michael     57   3
> >
> > I want to assign each of these three to different variables.  My only
> > problem is that the word and the numbers are always different and the
> space
> > between the words and numbers is always different as well.  Does anyone
> know
> > how I would assign the word and numbers to three different variables?
> > Thanks in advance.
> >
> > Mike.
> >
> >
> > _________________________________________________________________
> > Send and receive Hotmail on your mobile device: http://mobile.msn.com
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to