W3Schools

home HOME

JS Reference
JS Overview
JS Array
JS Boolean
JS Date
JS Math
JS Number
JS String
JS RegExp
JS Functions
JS Events

DOM Objects
DOM Window
DOM Navigator
DOM Screen
DOM History
DOM Location

DOM Document

DOM Anchor
DOM Area
DOM Base
DOM Body
DOM Button
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM IFrame
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Meta
DOM Object
DOM Option
DOM Select
DOM Style
DOM Table
DOM TableCell
DOM TableRow
DOM Textarea

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Forum

Helping W3Schools

JavaScript RegExp Object Reference


RegExp Object Methods

FF: Firefox, N: Netscape, IE: Internet Explorer

Method Description FF N IE
compile Change the regular expression (what to search for) 1 4 4
exec Search a string for a specified value. Returns the found value and remembers the position 1 4 4
test Search a string for a specified value. Returns true or false 1 4 4

String Object Methods that supports Regular Expressions

Method Description FF N IE
search Search a string for a specified value. Returns the position of the value 1 4 4
match Search a string for a specified value. Returns an array of the found value(s) 1 4 4
replace Replace characters with other characters 1 4 4
split Split a string into an array of strings 1 4 4


RegExp Modifiers

Property Description FF N IE
Pattern flags
i Ignore the case of characters 1 4 4
g Global search. Search all occurrences of the regular expression in a string 1 4 4
gi Global search, ignore case 1 4 4
m Multiline mode. Matches occurrences over multiple lines 1 4 4
Position Matching
^ Get a match at the beginning of a string 1 4 4
$ Get a match at the end of a string 1 4 4
\b Word boundary. Get a match at the beginning or end of a word in the string 1 4 4
\B Non-word boundary. Get a match when it is not at the beginning or end of a word in the string 1 4 4
?= A positive look ahead. Get a match if a string is followed by a specific string 1 4 4
?! A negative look ahead. Get a match if a string is not followed by a specific string 1 4 4
Literals
\0 Find a NULL character 1 4 4
\n Find a new line character 1 4 4
\f Find a form feed character 1 4 4
\r Find a carriage return character 1 4 4
\t Find a tab character 1 4 4
\v Find a vertical tab character 1 4 4
\xxx Find the ASCII character expressed by the octal number xxx 1 4 4
\xdd Find the ASCII character expressed by the hex number dd 1 4 4
\uxxxx Find the ASCII character expressed by the UNICODE xxxx 1 4 4
Character Classes
[xyz] Find any character in the specified character set 1 4 4
[^xyz] Find any character not in the specified character set 1 4 4
. (dot) Find any character except newline or line terminator 1 4 4
\w Find any alphanumeric character including the underscore 1 4 4
\W Find any non-word character 1 4 4
\d Find any single digit 1 4 4
\D Find any non-digit 1 4 4
\s Find any single space character 1 4 4
\S Find any single non-space character 1 4 4
Repetition
{x} Finds the exact (x) number of the regular expression grouped together 1 4 4
{x,} Finds the exact (x) or more number of the regular expression grouped together 1 4 4
{x,y} Finds between x and y number of the regular expression grouped together 1 4 4
? Finds zero or one occurrence of the regular expression 1 4 4
* Finds zero or more occurrences of the regular expression 1 4 4
+ Finds one or more occurrences of the regular expression 1 4 4
Grouping
( ) Finds the group of characters inside the parentheses and stores the matched string 1 4 4
(?: ) Finds the group of characters inside the parentheses but does not store the matched string  1 4 4
| Combines clauses into one regular expression and then matches any of the individual clauses. Similar to "OR" statement 1 4 4
Back references
( )\n Back reference. Uses the stored matched string. i.e. from the ( ) modifier 1 4 4

RegExp Object Properties

Property Description FF N IE
global Specifies if the "g" modifier is set 1 4 4
ignoreCase Specifies if the "i" modifier is set 1 4 4
input The string on which the pattern match is performed 1 4 4
lastIndex An integer specifying the index at which to start the next match 1 4 4
lastMatch The last matched characters 1 4 4
lastParen The last matched parenthesized substring 1 4 4
leftContext The substring in front of the characters most recently matched 1 4 4
multiline Specifies if the "m" modifier is set 1 4 4
prototype Allows you to add properties and methods to the object 1 4 4
rightContext The substring after the characters most recently matched 1 4 4
source The text used for pattern matching 1 4 4



Learn XML with <oXygen/> XML Editor - Free Trial!

oXygen - Probably The World's Best XML Editor   

oXygen helps you learn to define, edit, validate and transform XML documents. Supported technologies include XML Schema, DTD, Relax NG, XSLT, XPath, XQuery, CSS.

Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!

Do you have any XML related questions? Get free answers from the oXygen XML forum and from the video demonstrations.

Download a FREE 30-day trial today!




Jump to: Top of Page or HOME or Printer Friendly Printer friendly page

W3Schools provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2008 by Refsnes Data. All Rights Reserved.

Validate Validate W3C-WAI level A conformance icon W3Schools was converted to XHTML in December 1999
SITE SEARCH
 
About W3Schools
W3Schools Forum
Shopping Cart
ASP.NET
Shopping Cart
WEB HOSTING
$15 Domain Name
Registration
Save $20 / year!
UK Domain Names
UK Web Hosting

Alojamiento Web
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
Domain Name Registration
PHP MySQL Hosting
Top 10 Web Hosting
Web Hosting Providers
Web Hosting Company
UK Web Hosting
UK Reseller Hosting
Web Hosting
WEB BUILDING
Website Templates
Flash Templates
Website Builder
Internet Business Opportunity
Custom Programming
FREE Trial or Demo
Web Content Manager
Forms,Web Alerts,RSS
Ecommerce Software
XMLSpy XML Editor
Azbuz Blog
SHOPPING
UK Wholesalers
UK Wholesale
UAE Dubai Property
Private Student Loans
UK Dropshippers & Wholesalers Directory
EDUCATION
US Web Design Schools
HTML Exam
YELLOW PAGES
www.nettkatalogen.no
www.gulex.dk
www.gulex.se
www.gelbex.de
www.teloos.fi
www.teloos.fr
www.teloos.co.uk
www.teloos.at
www.teloos.de