Hommer Smith
Hommer Smith

Reputation: 27852

Regex detect Iphone App User agent (not web browser from Iphone) in Ruby

I have to differentiate between an incoming request from an Iphone App and an incoming request from an Iphone/Ipad (apple mobile device) web browser.
As stated in this question Iphone Web Browser vs Iphone Web Agent and for what I have seen in my logs, the difference between both user agents is that when coming from a web browser, the word "Safari" is added at the end. So my question is:

How would I create a regex similar to this one:

/Apple.*Mobile.*Safari/ 

But instead of .*Safari, making sure that Safari is not there. So I know the petition comes from the app.

Upvotes: 1

Views: 1424

Answers (1)

Qtax
Qtax

Reputation: 33908

You could do it with en expression like:

Apple.*Mobile(?!.*Safari)

Upvotes: 1

Related Questions