title: Remove prefix and suffix text of a token string
body: <p>I am here to ask your help, and this is my problem:</p>
  
  <p>I have created a token inside a text editor, and then select the token to edit it. But what I am afraid is that the text selected do not contain only the token but contains other extra text. So what I am going to ask is how can I remove the extra text before and after the token? I will provide an example of the token structure for you to understand my idea.</p>
  
  <p>This is the value of token: 
  <code>[[Token: there is some text]]</code></p>
  
  <p>The token contain text inside "[[" and "]]" including the quotation marks!</p>
  
  <p>That is what the token should be when selected, but what if the user not selected only the token string within the text, but also selected the whole text that contains the token?</p>
  
  <p>This an example for that situation: </p>
  
  <pre><code>prefixtext[[Token: there is some text]]suffixtext
  </code></pre>
  
  <p>Finally, I want to remove the prefix text and suffix text from the token to keep the token only when it selected from the text editor.</p>
  
  <p>Please using java script for solving this issue, and please assume that I am already got the text that contains token from text editor!</p>