Return the string value of the regular expression:
let pattern = new RegExp("Hello World", "g");
let text = pattern.toString();
Try it Yourself »
The toString() method returns the string value of the regular expression.
Return the string value of the regular expression:
let pattern = /Hello World/g;
let text = pattern.toString();
Try it Yourself »
toString()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
RegExpObject.toString()
None. |
Type | Description |
---|---|
String | The string value of the regular expression |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!