I am creating a regex library to work with HTML (I'll post it on MSDN Code when it's done). One of the methods removes any whitespace before a closing tag.

```
<p>See the dog run </p>

```

It would eliminate the space before the closing paragraph. I am using this:

```
    public static string RemoveWhiteSpaceBeforeClosingTag(string text)
    {
        string pattern = @"(\s+)(?:</)";
        return Regex.Replace(text, pattern, "</", Singleline | IgnoreCase);
    }

```

As you can see I am replacing the spaces with </ since I cannot seem to match just the space and exclude the closing tag. I know there's a way - I just haven't figured it out.