使用 RegEx 检测 WebKit 版本 525 及更低版本
我真的不擅长正则表达式!
我想专门检测版本 525 以下的 WebKit 浏览器。
我有一个正则表达式 [/WebKit/[\d.]+/.exec(navigator.appVersion)
] 可以正确返回 WebKit /5….…
,真的,我希望它只返回版本号,但如果浏览器不是 WebKit,则返回 null
,或者更好的是 0
。
例如,如果浏览器是 Trident、Presto 或 Gecko,则返回 null
,而如果浏览器是 WebKit,则返回其版本号。
为了澄清,我希望正则表达式检查 navigator.appVersion
是否包含 WebKit
,如果不包含,则返回 null,如果包含,则返回版本号。
我感谢您的所有帮助!
请让我们保持专注,不要与 jQuery 或其他类型调情,在这种情况下它太过分了。
I'm no good at Regular Expressions, really!
I would like to specifically detect WebKit browsers below version 525.
I have a regular expression [/WebKit/[\d.]+/.exec(navigator.appVersion)
] that correctly returns WebKit/5….…
, really, I'd like it to return only the version number, but if the browser isn't WebKit, return null
, or better still 0
.
For example, if the browser was Trident, Presto or Gecko, return null
, whereas if the browser is WebKit, return it's version number.
To clarify, I would like the regular expression to check if navigator.appVersion
contains WebKit
and if it does not, return null, if it does, return the version number.
I appreciate all your help!
Please let's keep this focused, let's not flirt with jQuery or the sort, it's overkill in this scenario.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对此提供了通常的警告:只有当您完全确定没有办法测试您想要使用的 WebKit 版本之间不同的实际功能时,您才应该使用它:
I'm providing this with the usual caveats: you should use this only if you are absolutely sure there is no way to test the actual feature you want to use that differs between WebKit versions: