I've been using the following user agent Regular Expression to detect mobile devices, but I recently came across a few resources that listed a whole host of mobile user agents that I had not heard of before.
The core of the regexp follows - please note the user agent string has had it's white-space removed. The check is also specifically case dependent. please ignore the newlines, they are for formatting only
/i[Pp]hone|[Mm]obile[Ss]afari|[Ww]indowsCE|[Ww]indows[Pp]hone| IE[Mm]obile|[Oo]pera[Mm]ini|[Oo]pera[Mm]obi|[Bb]lack[Bb]erry| [^A-Z]RIM[^A-Z]|[Ss]ony[Ee]ricsson|[Nn]okia|[^A-Z]MIB[^A-Z]/
These are the extra edge-case agents that I've found out about:
My question is, does anyone have any further suggestions, or possible keywords to remove that could cause false positives. For example I do not include
As a second note, many user-agents report as
Like Something - i.e.
Like Mobile Safari - should I filter these out of the equation, or if something is reporting this; is it also likely to be a mobile device.
In response to the first 'not an answer' :)
Does that make sense? The above is the only time where I would argue the use of user agent checking over anything more accurate.