private void SetNextMatch() { var textRange = new TextRange(TextBox.Document.ContentStart, TextBox.Document.ContentEnd); CurrentMatch = CurrentMatch?.NextMatch(); if (CurrentMatch == null || !CurrentMatch.Success) { CurrentMatch = FindRegex.Match(textRange.Text); } }