Yes, this should work for .foo.bar.foobar.etc.etc.etc.and.on.and.on

The changes were the same as for $FOO, just replaced \s with (\s\(?!?) at the beginning because otherwise ($FOO or (.foo wouldn't match (and also fixed the issue for ! in front of it as it would have had the same problem).