foreach (@test) { @test_filtered=grep{/^(([0-9]+)(?![^0-9]*[0-9]))/xsm} @test; }