public static WordToPrint Get(int index, Graphics g, PointF pos, RichTextBox rtb) { WordToPrint nextWord = new WordToPrint(); // match the words for same font / color Match m; CharToPrint nextChar = CharToPrint.Get(index, g, pos, rtb); m = wordSeparator.Match(nextChar.Text.ToString()); if (m.Success) { while (m.Success) { nextWord.Append(nextChar); index++; if (index >= rtb.Text.Length) { break; } nextChar = CharToPrint.Get(index, g, pos, rtb); m = wordSeparator.Match(nextChar.Text.ToString()); } // TODO: do what with .,/: and other punctuation at the end of a word. } else { nextWord.Append(nextChar); } return(nextWord); }