title: How to find the first number in a text field using a MySQL query?
body: <p>I like to return only the first number of a text stored in a column of a database table.
  User have put in page ranges into a field like 'p.2-5' or 'page 2 to 5' or '2 - 5'.
  I am interested in the '2' here.</p>
  
  <p>I tried to </p>
  
  <pre><code>  SELECT SUBSTR(the_field, LOCATE('2', the_field, 1)) AS 'the_number'
    FROM the_table
  </code></pre>
  
  <p>and it works. But how to get ANY number? </p>
  
  <p>I tried </p>
  
  <pre><code>  SELECT SUBSTR(the_field, LOCATE(REGEXP '[0-9], the_field, 1)) AS 'the_number'
    FROM the_table
  </code></pre>
  
  <p>but this time I get an error.</p>
  
  <p>Any ideas?</p>