in reply to regular expression ?!

Based on the single line example, I'd write it as:
s/\b(?=BM)/XXXXX_/g;