title: Ruby regular expression: distinguishing between iOS Safari & iOS Chrome
body: <p>Per the following documentation: <a href="https://developers.google.com/chrome/mobile/docs/user-agent" rel="nofollow">https://developers.google.com/chrome/mobile/docs/user-agent</a></p>
  
  <p>Here is Chrome for iOS UA String:</p>
  
  <pre><code>Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3
  </code></pre>
  
  <p>And here is Safari for iOS UA String:</p>
  
  <pre><code>Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3
  </code></pre>
  
  <p>As best as I can tell the difference going forward will be that Chrome includes "CriOS". I want to be able to distinguish between these two browsers and so set about doing that using a regular expression.</p>
  
  <p>Using:</p>
  
  <pre><code>/Gecko\) (?!CriOS)/
  </code></pre>
  
  <p>I'm able to do that but am paranoid as I am not including iPhone in the expression (perhaps this will also trigger on Android, etc.)</p>
  
  <p>I want to write the following regular expression that returns a match when:</p>
  
  <ol>
  <li>The string contains "iPhone"</li>
  <li>The string does not contain "CriOS"</li>
  </ol>
  
  <p>How would I go about doing that? </p>
  
  <p>FYI I've been using rubular for testing reg exp which has been awesome <a href="http://rubular.com/" rel="nofollow">http://rubular.com/</a></p>