$var =~ s!($pattern).*($pattern)!$1$2!g;