On Tue, Nov 4, 2008 at 6:12 AM, <[EMAIL PROTECTED]> wrote: > I have a string: " Confirming: yes Supplier > Telephone: 213-923-0392" > > I want to split the string so that i can capture yes in $conf and > 213-923-0392 in $tele. > > TIA for all the help, > > -ss > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > >
That is quite a simple thing to write, look at perlre<http://perldoc.perl.org/perlre.html>for some more information on how to do it. What I would try is the following: my $string = " Confirming: yes Supplier Telephone: 213-923-0392"; my ($conf, $tele) = $string =~ m/\b(\w{2,3})\b.*?\b(\d.*\d)/s; print "$conf $tele\n"; To explain what this does: \b # is a word boundry (\w{2,3}) # is a two or three character alphanumeric string (this part is captured in $1) \b # is another word boundry .*? # match anything but no more then the absolute minimum before the next part gets matched \b # again a word boundry (\d.*\d) # \d is a digit, .* is anything as much as you can find before the next match, \d is another digit (this part is captured in $2) But then again you can find all ot this in perlre<http://perldoc.perl.org/perlre.html>as well