title: How to count the number of matches for a given string in MySQL?
body: <p>An existing database contains a field call "dependent_ages", and some example data looks like "1,2,5" or "1yo and 3mo" or "4mo". </p>
  
  <p>The requirement is to convert such a string into an integer number, which is the number of substrings seperated by "," or "and". More precisely, the separator can be described as a regular expression ",|\sand\s". So for the above example the converted integers are 3, 2 and 1. Basically, I am interested in <em>how many</em> matches exists, not the <em>value</em> of those matches. So what ever the individual value is "14yo" or "4mo", it will be counted as 1. </p>
  
  <p>The question is to find a MySQL expression that can do this, for example</p>
  
  <pre><code>SELECT REGEXMATCHES(dependent_ages) as dependent_no ...
  </code></pre>
  
  <p><strong>UPADTE</strong></p>
  
  <p>Some answer/comments show some general misunderstand of the question so I clarified the question.</p>