| rightContext The rightContext property is a property of the RegExp object, and represents the string (of text, usually) following the most recent pattern match. syntax: RegExp.rightContext EXAMPLE globalRegExp = /the* /gi; var stringToSearch = "This is the RegExp search Text"; searchArray = globalRegExp.exec(stringToSearch); document.write("This is the RegExp search Result, rightContext : " + RegExp.rightContext); The first variable in the example (globalRegExp) specifies the text to search for ("the"), and the two switches to refine the search ("/gi"). See the RegExp object for a full list of search refining switches. The second variable, stringToSearch, contains the text that will be searched for a match to the search string set by globalRegExp. The searchArray contains the globalRegExp Object, with the exec() method, which performs the actual string search. The string to search through is given in the brackets, represented by the stringToSearch variable. Finally, the document.write statement writes a caption to the screen, along with the RegExp.rightContext contents. The string that is written to the screen should look like this: This is the RegExp search Result, rightContext : RegExp search Text The example returned the string which exists after (to the right of) the word "the". Hence the wording of "rightContext". |