<p>I need to match a string like "one. two.    three. four. five.  six. seven. eight. nine. ten. eleven" into groups of four sentences.  I need a regular expression to break the string into a group after every fourth period. Something like: </p>

<pre><code>  string regex = @"(.*.\s){4}";

  System.Text.RegularExpressions.Regex exp = new System.Text.RegularExpressions.Regex(regex);

  string result = exp.Replace(toTest, ".\n");
</code></pre>

<p>doesn't work because it will replace the text before the periods, not just the periods themselves.  How can I count just the periods and replace them with a period and new line character?</p>

Try defining the method
```
```
private string AppendNewLineToMatch(Match match) {
    return match.Value + Environment.NewLine;
}
```
```
and using
```
```
string result = exp.Replace(toTest, AppendNewLineToMatch);
```
```
This should call the method for each match, and replace it with that method's result. The method's result would be the matching text and a newline.
EDIT: Also, I agree with Oliver. The correct regex definition should be:
```
```
string regex = @"([^.]*[.]\s*){4}";
```
```
Another edit: Fixed the regex, hopefully I got it right this time.