$str =~ m/[^].*(.*)<\/image>.*?[^<\/story>]/s; ## <- w/o the "?" should work