in reply to need a regex
If I understand your question correctly:
$string=~s/(pattern1).*(pattern2)/$1$2/s; [download]