I do not think the alternation of space with "start of line" is a good thing . It's not good style and it looks like it can cause problems. Use ^\s* instead .
You don't need to remember the patterns so why use () to match the spaces ?
What would the /g modifier do in such a context ? I don't like it with a start of line.