It took a while to get there, but this pattern:
(.*((?!X).B|B(?!Z).))|(^B)|(B$)
looks for either (something that is not X)B or B(something that is not Z). The TDD code is as follows:
[Test]
public void TestPattern()
{
const string pattern = "(.*((?!X).B|B(?!Z).))|(^B)|(B$)";
Assert.IsFalse(Regex.IsMatch("Hello", pattern));
Assert.IsTrue(Regex.IsMatch("Hello ABC", pattern));
Assert.IsTrue(Regex.IsMatch("Hello DBE", pattern));
Assert.IsTrue(Regex.IsMatch("Hello ABE", pattern));
Assert.IsTrue(Regex.IsMatch("Hello FBG", pattern));
Assert.IsTrue(Regex.IsMatch("Hello ABC World", pattern));
Assert.IsTrue(Regex.IsMatch("Hello DBE World", pattern));
Assert.IsTrue(Regex.IsMatch("Hello ABE World", pattern));
Assert.IsTrue(Regex.IsMatch("Hello FBG World", pattern));
Assert.IsTrue(Regex.IsMatch("ABC World", pattern));
Assert.IsTrue(Regex.IsMatch("DBE World", pattern));
Assert.IsTrue(Regex.IsMatch("ABE World", pattern));
Assert.IsTrue(Regex.IsMatch("FBG World", pattern));
Assert.IsTrue(Regex.IsMatch("Hello DBE World XBZ", pattern));
Assert.IsTrue(Regex.IsMatch("Hello ABE World XBZ", pattern));
Assert.IsTrue(Regex.IsMatch("Hello FBG World XBZ", pattern));
Assert.IsFalse(Regex.IsMatch("Hello XBZ", pattern));
Assert.IsTrue(Regex.IsMatch("Hello XB", pattern));
Assert.IsTrue(Regex.IsMatch("Hello BZ", pattern));
Assert.IsTrue(Regex.IsMatch("XB Hello", pattern));
Assert.IsTrue(Regex.IsMatch("BZ Hello", pattern));
Assert.IsTrue(Regex.IsMatch("B", pattern));
}