RegExp

Team-Fly    

 
Webmaster in a Nutshell, 3rd Edition
By Robert Eckstein, Stephen Spainhour
Table of Contents
Chapter 11.  JavaScript


RegExp Core JavaScript 1.2; JScript 3.0; ECMA v3

Regular expressions for pattern matching
 /  pattern  /  attributes  

Constructor

 new RegExp(  pattern  ,  attributes  ) 

Regular expression patterns are expressed using a complex grammar that is summarized earlier in this chapter (Section 11.2.12).

Instance Properties

global

A read-only boolean that specifies whether the RegExp has the g attribute and therefore performs global matching.

ignoreCase

A read-only boolean that specifies whether the RegExp has the i attribute and therefore performs case-insensitive matching.

lastIndex

For global RegExp objects, this read/write property specifies the character position immediately following the last match; this is the first character examined for the next match.

multiline

A read-only boolean that specifies whether the RegExp has the m attribute and therefore performs multi-line matching.

source

A read-only string that holds the source text of the regular expression pattern , excluding slashes and attributes.

Methods

exec ( string )

Matches string against this RegExp and returns an array containing the results of the match, or null if no match was found. Element 0 of the array is the matching text. Subsequent elements of the array contain the substrings that matched the subexpressions within the RegExp. The returned array also has an index property that specifies the start position of the match.

test( string )

Returns true if string contains text matching this RegExp, or false otherwise .

See Also

String.match( ), String.replace( ), String.search( )


Team-Fly    
Top


Webmaster in a Nutshell
Webmaster in a Nutshell, Third Edition
ISBN: 0596003579
EAN: 2147483647
Year: 2002
Pages: 412

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net