title: Get number before the percent sign
body: <p>I have a string like that:</p>
  
  <pre><code>$string = "Half Board, 10% Off &amp; 100 Euro Star - Save £535";
  </code></pre>
  
  <p>The percentage can be anywhere in the string.</p>
  
  <p>This is what I have, but I don't like the fact that it has a preg_replace AND a loop operation, which are heavy. I'd like a ReGex expression that would do it in one operation.</p>
  
  <pre><code>$string = "Half Board, 10% Off &amp; 100 Euro Star - Save £535";
  $string_array = explode(" ", $string);
  $pattern = '/[^0-9,.]*/'; // non-digits
  
  foreach($string_array as $pc) {
  
      if(stristr($pc, '%')) {
  
          $percent = preg_replace($pattern, '', $pc);
          break;
      }
  }
  
  echo $percent;
  exit;
  </code></pre>