title: TinyMCE: How to insert content and select it?
body: <p>How does one insert, or better, replace the current selection with some content and then select it?</p>
  
  <p>Here's my text: <em>Hello <code>nice</code> world!</em></p>
  
  <p>As you can see <code>nice</code> is selected by the user. Now he clicks a button and this code is run:</p>
  
  <pre><code>editor.execCommand('mceReplaceContent', 'nasty');
  </code></pre>
  
  <p>This works just fine, the result is: <em>Hello nasty world</em>, but nothing is selected.</p>
  
  <p>How do I make it automatically select <code>nasty</code> in the result content?</p>
  
  <p>This seems like a very natural thing for one to want to do, but can't seem to find a straight-forward solution. I need this to work in mostly two cases 1) I am wrapping the selected text in a f.e. <code>span</code> element or 2) I am removing the wrapping <code>span</code> element.</p>
  
  <p>I know there are better ways of dealing with nodes, but I'm more concerned about the pure text scenario right now.</p>
  
  <p>Thanks in advance!</p>
  
  <p>P.S. I am using TinyMCE 3 not 4.</p>