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