user agents regex for mobile 1

user agents regex for mobile

/Mobile|iP(hone|od|ad)|Android|BlackBerry|BB|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/gi

Here is what the above code is Doing:
1. We’re using the re.compile() function to compile a regular expression pattern into a regular expression object.
2. We’re using the re.IGNORECASE flag so that our regular expression is case-insensitive.
3. We’re using the re.VERBOSE flag so that we can spread our regular expression over multiple lines and add comments.
4. We’re using the re.DOTALL flag so that a dot . will match all characters, including newline characters.
5. We’re using the re.MULTILINE flag so that the caret ^ and dollar $ anchors match at the beginning and end of each line, not just the beginning and end of the entire string.
6. We’re using the re.UNICODE flag so that any Unicode character can be matched.
7. We’re using the re.X flag so that we can add whitespace and comments to our regular expression for readability.
8. We’re using the re.DEBUG flag so that we can see the compiled version of our regular expression.

Similar Posts