title: How to use SUBSTRING using REGEXP in MySQL
body: <p>I have situation, where I have to substring regular expression from description using MySQL.</p>
  
  <p>Descritpion:</p>
  
  <blockquote>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac magna
    enim, eu adipiscing sapien. Cras lacinia vulputate elit, sed
    adipiscing felis interdum a. Cum sociis natoque penatibus et magnis
    dis parturient montes, nascetur ridiculus mus. Phasellus sit amet ante
    orci. <strong>D9801</strong> Quisque dignissim posuere quam, id suscipit nisl
    scelerisque nec.</p>
  </blockquote>
  
  <p>Where <strong>D9801</strong> is REGEXP. Every description has different content but my reg exp should looks like: <code>REGEXP 'D[[:digit:]]{4}'</code></p>
  
  <p>I know the REGEXP return only true/false value, but how can I make query to return only <strong>D9801</strong> value?</p>
  
  <p>I tried something like this:</p>
  
  <pre><code>SELECT 
  SUBSTRING (description, LOCATE(REGEXP 'D[[:digit:]]{4}', description), 5)
  FROM (
     SELECT "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac magna enim, eu adipiscing sapien. Cras lacinia vulputate elit, sed adipiscing felis interdum a. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus sit amet ante orci. **D9801** Quisque dignissim posuere quam, id suscipit nisl scelerisque nec." AS description
  ) temp
  </code></pre>
  
  <p>but now I know this is totally wrong...
  Any help will be appreciate.</p>