Regex: match non-android mobile user agents

I need to match an UA if it contains Mobile but not Android. I’ve tried with

Windows Phone|WPDesktop|BlackBerry|Opera Mini|Opera Mobi|Silk/|Kindle|(?!.*Android).*Mobile.*|SymbianOS

But it doesn’t always work.

Also, how can I exclude both ‘Windows’ and ‘Android’? (considering that Windows fakes himself as Android and iPhone…)

Edit: some test strings (android, iphone, wp, others):

Mozilla/5.0 (Linux; Android 4.1.2; GT-I8190N Build/JZO54K)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.94 Mobile

Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X)
AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D167

Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0;
Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 930) like iPhone OS 7_0_3
Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537

UCWEB/2.0 (Symbian; U; S60 V5; en-US; Nokia700) U2/1.0.0
UCBrowser/ U2/1.0.0 Mobile

Source: regex

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.