use re 'eval'; my $string = "hello world ballloon"; my $regex = qr/ll/; my @matches; () = $string =~ /(?=$regex)(?{push @matches, pos})./g; print join "\n", @matches; __END__ 2 14 15