Actually, since the others are numbers you could replace the last two \S+ with \d+ ----- Original Message ----- From: "Tanton Gibbs" <thgibbs@deltafarms.com> To: "Michael Stearman" <qazwsxe7@hotmail.com>; <beginners@perl.org> 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" <qazwsxe7@hotmail.com> > To: <beginners@perl.org> > 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: beginners-unsubscribe@perl.org > > For additional commands, e-mail: beginners-help@perl.org > > > > > -- > To unsubscribe, e-mail: beginners-unsubscribe@perl.org > For additional commands, e-mail: beginners-help@perl.org >Thread Previous