title: How to extract numeric value from a star-based rating system (works as string)
body: <p>If anyone has a better title, please edit so and remove this line.</p>
  
  <p>Quick question:
  I have some product with a 1 to 5 star-based rating. The rating is currently loading in via a JSON file and is as followed: "Rating": "5 stars". I just want to extract the number from that string, even if that string changes format.</p>
  
  <p>Let's forget the JSON part real quick.
  I can simply split the string and request the char that contains a numeric value <strong>if</strong> the string stays like that. But what if you can rate a product 1-10 stars? Extracting the first numeric value as char doesn't work anymore. Extracting ALL numeric values won't work if the string is something along the lines of <code>"This product has 27 reviews with an average of 4 stars"</code> since it will get confused with the number of reviews. Keeping that in mind, splitting it on ' ' (spaces) won't work either if the string is <code>"4stars"</code> instead of <code>"4 stars"</code>.</p>
  
  <p>Can I <strong>easily</strong> extract this rating value while keeping a potentially ever-changing format in mind? Or will it be too much work and have to write a small adapter interface or strategy pattern to extract this?</p>