How do I delete mobile devices ignoring the iPad

I want to ignore the iPad as a mobile device in my application

I am currently using this expression to detect mobile devices:

request.user_agent =~ /Mobile|webOS/

Standard material. The iPad Agent line looks something like this:

Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B405 Safari/531.21.10

I tried the following without success:

request.user_agent =~ /!(iPad)(Mobile|webOS)/

Please let me know what is wrong with the expression.

Thank.

+3
source share
1 answer

You can use negative matches or

request.user_agent =~ /Mobile|webOS/ && !(request.user_agent =~ /iPad/)
+17
source

Source: https://habr.com/ru/post/1764721/


All Articles