Class RegExp

Object
  extended by RegExp

public class RegExp
extends Object

A regular expression object contains the pattern of a regular expression. It has properties and methods for using that regular expression to find and replace matches in strings. In addition to the properties of an individual regular expression object that you create using the RegExp constructor function, the predefined RegExp object has static properties that are set whenever any regular expression is used.


Field Summary
 boolean ignoreCase
          Whether or not the "i" flag is used with the regular expression.
 
Method Summary
 String[] exec(String str)
          Executes a search for a match in its string parameter.
 String fromCharCode(Number... num)
          Returns a string created by using the specified sequence of Unicode values.
 Number indexOf(String searchValue, Number fromIndex)
          Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex, or -1 if the value is not found.
 Number lastIndexOf(String searchValue, Number fromIndex)
          Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
 String substring(Number start, Number end)
          Returns a subset of a String object.
 boolean test(String str)
          Executes the search for a match between a regular expression and a specified string.
 String toLowerCase()
          Returns the calling string value converted to lowercase.
 String toUpperCase()
          Returns the calling string value converted to uppercase.
 
Methods inherited from class Object
toString
 

Field Detail

ignoreCase

public boolean ignoreCase
Whether or not the "i" flag is used with the regular expression.

Method Detail

toUpperCase

public String toUpperCase()
Returns the calling string value converted to uppercase. The toUpperCase method returns the value of the string converted to uppercase. toUpperCase does not affect the value of the string itself.


fromCharCode

public String fromCharCode(Number... num)
Returns a string created by using the specified sequence of Unicode values. This method returns a string and not a String object. Because fromCharCode is a static method of String, you always use it as String.fromCharCode(), rather than as a method of a String object you created.

Parameters:
num - An integer between 0 and 1 less than the length of the string. The default value is 0.

test

public boolean test(String str)
Executes the search for a match between a regular expression and a specified string. Returns true or false. When you want to know whether a pattern is found in a string use the test method (similar to the String.search method); for more information (but slower execution) use the exec method (similar to the String.match method).

Parameters:
str - The string against which to match the regular expression.

toLowerCase

public String toLowerCase()
Returns the calling string value converted to lowercase. The toLowerCase method returns the value of the string converted to lowercase. toLowerCase does not affect the value of the string itself.


substring

public String substring(Number start,
                        Number end)
Returns a subset of a String object.

Parameters:
start - An integer between 0 and 1 less than the length of the string.
end - An integer between 0 and 1 less than the length of the string.

lastIndexOf

public Number lastIndexOf(String searchValue,
                          Number fromIndex)
Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex. Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is stringName.length - 1.

Parameters:
searchValue - A string representing the value to search for.
fromIndex - The location within the calling string to start the search from. It can be any integer between 0 and the length of the string. The default value is the length of the string.

exec

public String[] exec(String str)
Executes a search for a match in its string parameter. Returns a result array. As shown in the syntax description, a regular expression's exec method can be called either directly, (with regexp.exec(str)) or indirectly (with regexp(str)). If you are executing a match simply to find true or false, use the test method or the String search method. If the match succeeds, the exec method returns an array and updates properties of the regular expression object. If the match fails, the exec method returns null.

Parameters:
str - The string against which to match the regular expression.

indexOf

public Number indexOf(String searchValue,
                      Number fromIndex)
Returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex, or -1 if the value is not found. Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character of a string called stringName is stringName.length - 1.

Parameters:
searchValue - A string representing the value to search for.
fromIndex - The location within the calling string to start the search from. It can be any integer between 0 and the length of the string. The default value is 0.