w3schools    w3Schools
Search W3Schools :
   
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
ADVERTISEMENTS

XML Certification
Download XML editor
Custom Programming
 
Table of contents
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 Tutorials
W3Schools Forum

Helping W3Schools

 

JavaScript RegExp Object Reference


The RegExp Object

The regular expression object describes a pattern of characters.

Syntax for creating a RegExp object:

var txt=new RegExp(pattern,attributes);
or
var txt=/pattern/attributes;
  • pattern specifies the pattern of the regular expression
  • attributes specifies global ("g"), case-insensitive ("i"), and multiline matches ("m")

RegExp Object Properties

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

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

RegExp Object Methods

Method Description FF N IE
compile() Change the regular expression 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

Modifier Description FF N IE
i Perform case-insensitive matching 1 4 4
g Perform a global match. Find all matches (do not stop after the first match) 1 4 4
gi Perform a global case-insensitive match. Find all matches (do not stop after the first match) 1 4 4
m Perform multiline matching 1 4 4

RegExp Modifiers

Property Description FF N IE
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



The tools you need to build your web project!

Instant Demo

Ektron CMS400.NET Version 7.6 delivers all of the flexibility and features you need to deploy the Web site you want, quickly and efficiently.

learn more...

 

 

 

6 ways to take your site to the next level with Ektron:

Social Networking Create site stickiness through social networking. Keep it personal, relevant and interactive and they'll come back for more.
Open API Keep it open. Your site needs to be ready and able to connect to outside services. Ektron's open API gives you maximum flexibility.
Document Management Streamline content and document management. Users need to quickly and intuitively find and add information.
Content Authors Empower your content authors. Reduce IT bottlenecks by allowing business users to create and edit Web content and forms.
Taxonomy Climb to the top of search rankings. SEO tools, URL aliasing and eCommerce for your digital marketing strategy
Web 2.0 Tools Add powerful Web 2.0 tools like blogs, wikis, forums, geo-mapping, rating systems and RSS feeds easily.
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today.

 
WEB HOSTING
dotnetbutton
Dynamic button image generation
$15 Domain Name
Registration
Save $20 / year!
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE 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
Download XML editor
FREE Flash Website
FREE Web Templates
EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification
Home HOME or Top of Page Validate   Validate   W3C-WAI level A conformance icon Printer Friendly  Printer Friendly

W3Schools is for training only. We do not warrant the correctness of its content. 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-2009 by Refsnes Data. All Rights Reserved.