http://qs321.pair.com?node_id=11123088


in reply to Trim Two Characters On Line

perl -le 'for(@ARGV){ s/(?=SUM).*\K..//; print }' abcSUMcdexx abcSUXcd +exx abcSUMc

Outputs:

abcSUMcde abcSUXcdexx abcSU

( borrowing bits and pieces and ideas from other monks... )