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

JavaScript match() Method


String Object Reference JavaScript String Object

Definition and Usage

The match() method returns the matches when matching a string against a regular expression.

This method returns an array of information, or null if no match is found.

Syntax

stringObject.match(regexp)

Parameter Description
regexp Required. A regular expression object. Read more about the RegExp object


Example

Example

Perform a global, case-insensitive search for "ain":

<script type="text/javascript">

var str="The rain in SPAIN stays mainly in the plain";
var patt1=/ain/gi;
document.write(str.match(patt1));

</script>

The output of the code above will be:


Try it yourself »


String Object Reference JavaScript String 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