w3schools
  
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About

JavaScript RegExp g Modifier


RegExp Object Reference JavaScript RegExp Object

Definition and Usage

The g modifier is used to perform a global match (find all matches rather than stopping after the first match).

Syntax

new RegExp("regexp","g")

or simply:

/regexp/g


Examples

Example 1

Do a global search for "is":

var str="Is this all there is?";
var patt1=/is/g;

The marked text below shows where the expression gets a match:

Is this all there is?

Try it yourself »

Example 2

Do a global, case-insensitive search for "is":

var str="Is this all there is?";
var patt1=/is/gi;

The marked text below shows where the expression gets a match:

Is this all there is?

Try it yourself »


RegExp Object Reference JavaScript RegExp Object

DreamTemplate


WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting
Top Web Hosting
Windows Hosting
WEB BUILDING
XML Editor – Free Trial!
FREE Flash Website
FREE Web Templates
FLIGHT TICKETS
Find the cheapest flight
to any destination now!
EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification
STATISTICS
Browser Statistics
Browser OS
Browser Display