Thanks all for the quick response.
In perl there is a "/g" option which can be used for multi-matching.

# perl -le '$x="123 456 789"; @x=$x=~/\d{3}/g; print "@x"'
123 456 789

I try to find ruby's instead one, but never thought there is already a
scan method available.
Thanks.