On Feb 9, 2005, at 2:10 PM, Jos Backus wrote:

> Given Perl's
>
>     $_ = "123 foo";
>
>     s/^(\d+)\s+//;
>     $pid = $1;
>
>     print "$_\n$pid\n";
>
> all I can come up with is
>
>     line = "123 foo"
>
>     pid = nil
>     line.sub!(/^(\d+)\s+/) {pid = $1; ''}
>
>     puts line, pid
>
> Is there a better way perhaps?

I don't think I understand the question.  Ruby supports replacement 
with and empty string and even $1, just like Perl.

line.sub!(/^((\d+)\s+/, "")
puts "#{line}\n#{$1}"

Hope that helps.

James Edward Gray II