RegExp.prototype.compile()
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
注意:仅出于兼容性原因指定
compile()
方法。使用compile()
会导致原本不可变的正则表达式源和标志变得可变,这可能会打破用户的期望。你可以使用RegExp()
构造函数来构造新的正则表达式对象。¥Note: The
compile()
method is only specified for compatibility reasons. Usingcompile()
causes the otherwise immutable regex source and flags to become mutable, which may break user expectations. You can use theRegExp()
constructor to construct a new regular expression object instead.
RegExp
实例的 compile()
方法用于在创建 RegExp
对象后使用新源和标志重新编译正则表达式。
¥The compile()
method of RegExp
instances is used to recompile a regular expression with new source and flags after the RegExp
object has already been created.
语法
参数
返回值
示例
使用编译()
规范
Specification |
---|
ECMAScript Language Specification # sec-regexp.prototype.compile |
浏览器兼容性
BCD tables only load in the browser
也可以看看
¥See also