title: Find a substring after a matched pattern in t-sql
body: <p>This may be really easy but T-SQL is far from my forte.</p>
  
  <p>I have a bunch of really long strings that contain a segment that looks like this:</p>
  
  <pre><code>   ~GS^PO^007941230X^107996118^20130514^
  </code></pre>
  
  <p>I'd like to extract 007941230X out of this. The length of this substring will vary but the format will always be:</p>
  
  <pre><code>  ~xxxx^.....^xxxxx^~GS^PO^jjjjjjjj^xxx^xxxx^....~
  </code></pre>
  
  <p>Does anyone know how to get the substring of the values for j in t-sql?</p>
  
  <p>I was trying to use patindex somehow but can't figure it out.</p>