in reply to Negating a leading whitespace

Assume you are looking for "AB", then use:
/^(?!\s).*AB/
or if you can use two regexes:
!/^\s/ && /AB/
the latter is likely to be faster.