in reply to RegEx Beginning of line or whitespace match
This matches if the "for(" has no characters at all before it (== at beginning of line) or if there are whitespace characters. You were missing the anchor, I think.