RegExp.prototype.ignoreCase

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

概述

ignoreCase 属性表明正则表达式是否使用了 "i" 标志。ignoreCase 是正则表达式实例的只读属性。

RegExp.prototype.ignoreCase 的属性特性
可写
可枚举
可配置

描述

ignoreCase 的值是布尔对象,如果使用了"i" 标志,则返回 true;否则,返回 false。"i" 标志意味着在字符串进行匹配时,应该忽略大小写。

你无法直接更改此属性。

示例

示例:使用 ignoreCase

js
var regex = new RegExp("foo", "i");

console.log(regex.ignoreCase); // true

规范

Specification
ECMAScript® 2025 Language Specification
# sec-get-regexp.prototype.ignorecase

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
ignoreCase
Prototype accessor property (ES2015)

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见