lastIndex Summary Sets or retrieves the last index for a global match. Signatures Click on a signature to select it and view its documentation. public property int lastIndex() public property void lastIndex(int index) Usage public property int lastIndex() public property void lastIndex(int index) Returns The last index in the string to start the regular expression match from. The specified index for the last index. Parameters index The index to set the lastIndex to. Description This getter property will return the lastIndex for the regular expression. The lastIndex is the index in the string that the regular expression will start matching from in a global match (using the g flag). This setter property will set the lastIndex for the regular expression to start a global match from. Examples Basic Usage 12345import System; System.RegExp re = new System.RegExp(/a/g);bool match = re.test("There is a way.");Console.log(re.lastIndex); // 13 Basic Usage 12345import System; System.RegExp re = new System.RegExp(/a/g);re.lastIndex = 11; // set the last index AFTER the first occurrence of "a"Console.log(re.exec("There is a way.")); // ["a"] // the match comes from the 'a' in "way", not "a" (the indefinite article) Share HTML | BBCode | Direct Link