while ($string =~ /(pattern)/g) { do_something_with($1); } #### while ($string =~ /(?=(patter))/g) { do_something_with($1); }