Search code examples
javascriptagent

With userAgent.match(), what does the "/i" mean at the end?


Examples can be found at these locations:

JavaScript how to check User Agent for Mobile/Tablet

Detecting a mobile browser

For the problem I am working on, I will not be using Javascript to detect the user agent, so the answer does not directly affect my problem. However, while searching for the correct user agents, I kept seeing "/iPad/i", "/iPhone/i", "/Android/i" and so on. What does the "/i" mean after "/iPad"? Is it simply a regular expression, and to tell the Javascript function to be case insensitive?

I tried googling for userAgent.match() to get more information about the function itself, and to see what arguments it accepts, but I had no luck.

To elaborate: I've read a few sites that say user agent sniffing is bad news, so if you're wondering why I'm sniffing user agent, it's to compile a list of email addresses. Mac uses commas, Windows uses semi-colons. I recently became aware that iOS also uses commas, so my program was breaking on iPad. So, I need to update my user agent sniffing code.


Solution

  • It meant as case insensitive

    so "/iPhone/i" will match with iphone, IPHONE or IpHOne