title: Extract Number before a Character in a String Using Python
body: <p>I'm trying to extract the number before character "M" in a series of strings. The strings may look like:</p>
  
  <pre><code>"107S33M15H"
  "33M100S"
  "12M100H33M"
  </code></pre>
  
  <p>so basically there would be a sets of numbers separated by different characters, and "M" may show up more than once. For the example here, I would like my code to return:</p>
  
  <pre><code>33
  33
  12,33 #doesn't matter what deliminator to use here
  </code></pre>
  
  <p>One way I could think of is to split the string by "M", and find items that are pure numbers, but I suspect there are better ways to do it. Thanks a lot for the help.</p>