title: Get part of the text from RichTextBox
body: <p>Can someone please tell me what is wrong with this. I am trying to get text between several characters before caret and the caret."comparable" is never longer than the actual text in the <code>RichTextBox</code>.</p>
  
  <p>This is the code that I have: </p>
  
  <pre><code>int coLen = comparable.Length;
  TextPointer caretBack = rtb.CaretPosition.GetPositionAtOffset(coLen, 
      LogicalDirection.Backward);
  TextRange rtbText = new TextRange(caretBack, rtb.CaretPosition);
  string text = rtbText.Text;
  </code></pre>
  
  <p>This returns <code>text = ""</code></p>
  
  <p>Please help!</p>