##
use warnings;
####
$str = s/.*\-D*?//;
####
$_ = "text1 text2 -f -DFLAG1 -global -DFLAG2 -DFLAG1";
s/.*?(?=-D)//;
print "$_\n";
####
s/[^-]+-[^-]+//;
####
s/
[^-]+ # Negated character class - match one or more
# of anything that is not a dash: "text1 text2 "
- # match the dash: "-"
[^-]+ # Negated character class - match one or more
# of anything that is not a dash: "f "
//x;