Is there a chance that WordA can occur in the string multiple times? If not, I think this would work:
concat(substring(field, 1, 1000 * not(contains(field, "WordA"))), substring(concat(substring-before(field, "WordA"), "WordB", substring-after(field, "WordA")), 1, 1000 * contains(field, "WordA")))