javascript - What is /i in navigator.userAgent.match -
i'm curious /i
in:
var ismobile = { android: function() { return navigator.useragent.match(/android/i); }, blackberry: function() { return navigator.useragent.match(/blackberry/i); }, ios: function() { return navigator.useragent.match(/iphone|ipad|ipod/i); }, opera: function() { return navigator.useragent.match(/opera mini/i); }, windows: function() { return navigator.useragent.match(/iemobile/i); }, any: function() { return (ismobile.android() || ismobile.blackberry() || ismobile.ios() || ismobile.opera() || ismobile.windows()); }}; }
source: https://www.sitepoint.com/navigator-useragent-mobiles-including-ipad/
could tell me /i
exactly? i've searched lot of websites things navigator.useragent.match none explain /i
is, /g
/heregoesregex/flags
literal regular expression in many languages (including javascript). after last slash can specify flags regular expression. list of available flags javascript includes:
- g global search.
- i case-insensitive search.
- m multi-line search.
- y "sticky" search matches starting @ current position in target string
Comments
Post a Comment