chen li wrote:
>
> I need a regular expression to process some data but
> get stuck. I wonder if anyone here might have a clue.
>
>  input:
>  my $line='group A 1 2 3 4';# separated by space
>
>  results:
>  my @data=("group A ",1,2,3,4);

My offering:

  my @data = $line =~ /\S+/g;
  splice @data, 0, 2, join ' ', @data[0,1] while $data[1] =~ /\D/;

which differs in that it doesn't add the (presumably unnecessary) space after
the group letter.

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to