.*A.*\s.*B.*|.*B.*\s.*A.*
Note the use of “+” between A and B. This is necessary so that you match the individual A and B. If this is not a requirement, then Łukasz Lew's answer is correct.
UPDATE: Changed according to Brian's wonderful comment below. The above expression will recognize A separated from B (or vice versa) with at least one whitespace character (space, tab or line break) between the two areas of interest.
source share