Can you provide a specific example? Maybe this?
Hold[(L^4)*(lm^4) + 3 ((L^4)*(lm^4)) + ((L^4)*(lm^4))^2] /. ((L^4)*(lm^4)) -> B // ReleaseHold
(* 4 B + B^2 *)
The Hold
is required to prevent the expression from being simplified before the replacement.