I was thinking of putting an explanation of the pattern in for this one
b?\s?\bYourWord\b(?(1)\s?)[/b]
The basics of it are that you test if you're at the start of a line, and to do that you use the ^ and put it into brackets, which for those who've done a bit of regex with know also creates a capturing pattern with 1 as its id, but it must be optional, and that's what the question mark does.
B?[/B] check if we're at the start of the line [the ], do a capture so we can check it later [the brackets], but make it optional [the question mark]
\s?\bYourWord\b is grab a space before the word if it's there [\s?], and the word itself
The last bit tests whether the optional start of line pattern actually did capture anything, and if so also says take whitespace from after the word
B[/B] means did 1 capture anything? If so optionally scoop up another space.
So the logic of the whole expression is always grab a space from in front of the word, but if you're at the start of a line then also grab a space after.
That's going to be unintelligible drivel, isn't it. This will probably help more:
http://www.regular-expressions.info/conditional.html