RegExp.global

JavaScript 1.2+, JScript 3.0+c Nav4+, NES3+, IE4+ Syntax

							regexp.global

Description

The global property of the RegExp object specifies whether or not the g flag is used with the regular expression. If so, a global pattern match will be performed.

Example

Listing 6.216 shows how the global property is used.

Listing 6.216 Example of global Property
 <html> <body> <script language="JavaScript"> <!–– Hide // defines a regular expression on the pattern "if" // with the global flag set. var myPat = new RegExp("if", "g"); // define a string var str = "What if Angela is wondering about gifs?"; // store results of exec into myArray myArray = myPat.exec(str); document.write("The value of RegExp.global is: " + "<b>" + myPat.global ...

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.