$str =~ /^(\d+) /g and $str =~ /\G(.{$1})/; [download]
In reply to Re: Using previous match in the same matching regexp by japhy in thread Using previous match in the same matching regexp by cyberconte