We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

概述

source 属性返回一个值为当前正则表达式对象的模式文本的字符串,该字符串不会包含正则字面量两边的斜杠以及任何的标志字符。

示例

var regex = /fooBar/ig;

console.log(regex.source); // "fooBar",不包含 /.../ 和 "ig"。

规范

规范名称 规范状态 备注
ECMAScript 3rd Edition. Standard source 是正则对象自身的数据属性
ECMAScript 5.1 (ECMA-262)
RegExp.prototype.source
Standard  
ECMAScript 2015 (6th Edition, ECMA-262)
RegExp.prototype.source
Standard source 成为了正则对象原型上的一个访问器属性

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

相关链接

文档标签和贡献者

此页面的贡献者: ziyunfei, yenshen
最后编辑者: ziyunfei,