• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

The RegExp Object

Besides regular expression objects, there is also a global object named RegExp that holds data about the most recent regular expression operation. This object always exists—don’t confuse it with regular expression objects of the kind just covered. The global RegExp object holds data about the most recent regular expression operation, whereas regular expression objects hold data about their particular regular expression operations. You can find the properties of the RegExp object in Table 20.4.

Table 20.4. The Properties of the RegExp Object
Property NS2 NS3 NS4 NS6 IE3a IE3b IE4 IE5 IE5.5 IE6
index       x x x x
  Read-only
  This property holds the character position where the first successful match began in the string you’re searching.
input   x x     x x
  Read/write
  This property holds the string on which a regular expression search was performed. There’s a shortcut for this property, following the Perl language: $_. (That is, you can reach this property’s value as RegExp.input or RegExp.$_.)
lastIndex       x x x x
  Read-only
  Returns the character position where the next match begins in a searched string.
lastMatch   x x     x x
  Read-only
  This property holds the last matched characters from any regular expression search.
lastParen   x x     x x
  Read-only
  This property holds the last parenthesized submatch from any regular expression search.
leftContext   x x     x x
  Read-only
  This property holds the characters from the beginning of the string up to the position before the beginning of the last match.
rightContext   x x     x x
  Read-only
  This property holds the characters from the position following the last match to the end of a string.
$1...$9   x x   x x x x
  Read-only
  These properties hold the various back matches to submatches that matched sections of the regular expression in parentheses.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint