title: Extract substring from string in SQL
body: <p>I need to extract a text that is surrounded by <code>***[some text]</code> strings, like in the following example:</p>
  
  <pre><code>some text
  some text
  ***[some text]
  THIS SHOULD BE EXTRACTED
  ***[some text]
  some text
  some text
  some text
  some text
  some text
  ***[some text]
  THIS SHOULD BE EXTRACTED TOO
  ***[some text]
  some text
  </code></pre>
  
  <p>the output should be:</p>
  
  <pre><code>THIS SHOULD BE EXTRACTED
  THIS SHOULD BE EXTRACTED TOO
  </code></pre>
  
  <p>I tried <code>PATINDEX</code> like here, but couln't find the way to extract the string.</p>
  
  <pre><code>PATINDEX('%[*][*][*][[]%]%%[*][*][*][[]%]%',@Text)
  </code></pre>
  
  <p>I am looking forward to hearing any suggestions.</p>