title: Find numbers in String and compute, insert back in String (Swift)
body: <p>I'm trying to offer ingredient scaling feature in my recipe manager app.
  Scaled result is for display purpose only and won't be persisted.</p>
  
  <p>Let's say we have a fried rice recipe and its ingredient consists of <code>2 bowls of rice, 1 egg, 1 tbsp soy sauce</code> and this is for 2 serving(persons).</p>
  
  <p>There are - and + buttons among this number '2' to increment/decrement serving which would look like
  <code>- 2 +</code></p>
  
  <p>Whenever the - and + icons are pressed, it will run a function to get numbers from an ingredient String and get ingredient quantities of 1 serving. Recipe data can be saved in any serving size so for scaling I always need to start from 1 serving portion.
  Based on my example here, 1 serving ingredient quantity should be <code>1 bowls of rice, 0.5 egg, 0.5 tbsp soy sauce</code>, thus <code>[1, 0.5, 0.5]</code>.</p>
  
  <p>Then I can scale ingredient quantity based on user action.
  So far I have figured out the following which gets the number string out of the whole ingredient string, make it into an array and convert it to Int array.</p>
  
  <pre><code>if recipe.ingredients != "" {
      let ingredientStr = recipe.ingredients
      let numStr = ingredientStr?.componentsSeparatedByCharactersInSet(
                      NSCharacterSet
                          .decimalDigitCharacterSet()
                          .invertedSet)
      let array = numStr!.filter({ $0 != "" })
      var intArray = array.map{ Int($0)! }
  }
  </code></pre>
  
  <p>I've tried various ways to calculate numbers from here but failed to get expected numbers. What I haven't accomplished is:  </p>
  
  <ul>
  <li>Get 1 serving quantities</li>
  <li>Scale quantities based on +, - action</li>
  <li>Insert the arithmetic result back in the original String to display</li>
  </ul>