title: using regular expression in sql
body: <p>I have the following rows in my table</p>
  
  <pre><code>COL1                       EXTRA         DOUBLE       TEST
  12 TEST
  123 EXTRA
  125 EXTRA 95 DOUBLE
  EXTRA 45 99 DOUBLE 
  </code></pre>
  
  <p>I am using regular expressions to filter out the rows and move them appropriately to different columns. So:</p>
  
  <ul>
  <li>For the first row, I want 12 to be extracted and put in column TEST.</li>
  <li>For the second row, I want 123 to be extracted and put in column EXTRA.</li>
  <li>For 3rd row, I want 125 to be extracted and put in column EXTRA.</li>
  <li>I want to ignore 95.</li>
  <li>For the last row, I want 45 to be extracted and put in column EXTRA.</li>
  </ul>
  
  <p>I can extract the values and put them in appropriate columns through my query, I am using this regular expression for extracting the values: </p>
  
  <pre><code>'%[0-9]%[^A-Z]%[0-9]%'
  </code></pre>
  
  <p>the problem with this regular expression is that it extracts 12, but it does not extract 123 from the second row, if I change the regular expression to: </p>
  
  <pre><code>'%[0-9]*%[^A-Z]%[0-9]%' 
  </code></pre>
  
  <p>then it extracts 123, but for the third row, it concatenates 125 with 95 so I get 12595. Is there any way I can avoid 95 and just get the value 125? If I remove the star then it does not do any concatenation.</p>
  
  <p>Any help will be appreciated. I posted this question before, but some of you were asking for more explanation so I posted a new question for that.</p>