RegExp.source

JavaScript 1.2+, Jscript 3.0+ Nav4+, NES3+, IE4+ Syntax

							regexp.source

Description

The source property of the RegExp object represents the text being used for pattern matching.

Example:

Listing 6.225 shows how the source property is used.

Listing 6.225 Example of source Property
<html>
<body>

<script language="JavaScript">
<!–– Hide

exp = new RegExp("am", "g");
str = "This is just a sample sentence.";
myArray = exp.exec(str);

document.write("The source is: " + "<b>" + exp.source + "</b>");
// End Hide ––>
</script>

</body>
</html>
							
							
						

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.