Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
All Objects
String Object
METHOD: String::match
object.
match
(regexp)
This method is used to match a specifed regular expression against a string. If one or more matches are made, an array is returned that contains all of the matches. Each entry in the array is a copy of a string that contains a match. If no match is made, a null is returned.
To perform a global match you must include the 'g' (global) flag in the regular expression and to perform a case-insensitive match you must include the 'i' (ignore case) flag.
The following code uses the match method to search the characters in the myString string for a match with the specified regular expression and displays the resulting string in the browser. Note that the 'i' flag is used to make the search case-insensitive.
Code:
myString = new String("DevGuru.com")
myRE = new RegExp("guru", "i")
results = myString.match(myRE)
for(var i =0; i < results.length; i++)
{
document.write(results[i])
}
Output:
Guru
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information