$_ = "text1 text2 -f -DFLAG1 -global -DFLAG2 -DFLAG1"; $str = s/.*\-D*?//; print "$_\n";