JavaScript RegExp source attribute

Definition and usage

source The property returns the text of the RegExp pattern.

description

RegExp object properties source It is a read-only string. It stores the text of the RegExp pattern. This text does not include the delimiters used directly in the regular expression literals, nor does it include the flags g, i, m.

example

let text = "Visit CodeW3C.com";
let pattern = /W3S/g;
let result = pattern.source;

try it yourself

syntax

regexp.source

return value

type description
string RegExp pattern text.

browser supports

source เป็นคุณสมบัติของ ECMAScript1 (ES1)

ทุกบราวเซอร์สนับสนุน ES1 (JavaScript 1997) ทั้งหมด:

Chrome IE Edge Firefox Safari Opera
สนับสนุน สนับสนุน สนับสนุน สนับสนุน สนับสนุน สนับสนุน