Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

JScript Regular Expression Object

The Regular Expression object contains a regular expression pattern.

Methods: JScript Regular Expression Object

JScript Regular Expression Object compile Method

Compiles a regular expression into an internal format.

JScript Regular Expression Object exec Method

Executes a search for a match in a specified string.

JScript Regular Expression Object test Method

Tests whether a pattern exists in a string.

Properties: JScript Regular Expression Object

JScript Regular Expression Object global Property

Indicates whether the global switch (g) has been used.

JScript Regular Expression Object ignoreCase Property

Indicates whether the ignore case switch (i) has been used.

JScript Regular Expression Object lastIndex Property

The index to start the next match.

JScript Regular Expression Object source Property

The text of the regular expression pattern.

Syntax 1: JScript Regular Expression Object

var regularexpression = /pattern/[switch]

Syntax 2: JScript Regular Expression Object

var regularexpression = new RegExp("pattern",["switch"])

Arguments: JScript Regular Expression Object

pattern

The regular expression pattern to use. If you use Syntax 1, delimit the pattern by "/" characters. If you use Syntax 2, enclose the pattern in quotes. Required.

switch

Enclose switch in quotes if you use Syntax 2. Available switches are: i (ignore case) g (global search for all occurrences of pattern) gi (global search, ignore case). Optional.

Remarks: JScript Regular Expression Object

Regular Expression objects store patterns used when searching strings for character combinations. After the Regular Expression object is created, it is either passed to a string method, or a string is passed to one of the regular expression methods. Information about the most recent search performed is stored in the RegExp object.

Use Syntax 1 when you know the search string ahead of time. Use Syntax 2 when the search string is changing frequently, or is unknown, such as strings taken from user input.

The pattern argument is compiled into an internal format before use. For Syntax 1, pattern is compiled as the script is loaded. For Syntax 2, pattern is compiled just before use, or when the compile method is called.

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.