Javascript Regex LastIndex PropertiesJavaScript LastIndex property helps to return the last index of the match string. We can get the regular expression pattern to match and get the last position before starting the next value. It helps with long string and array values operation and filter. The exec and test method resets the "0" value if the string does not match. SyntaxThe following syntax is used to get the last index before starting the next value. Supported BrowsersThe browsers supported by RegExp's last index properties are given below:
ExamplesThe following examples are the last position of the matching string. Example 1: The example shows the last position of the match character for the lastIndex property. Here, we use regex directly with the lastIndex keyword. Output The output shows the last index position of the matching string. Example 2: The example shows the array function's last position of the matching character for the lastIndex property. Output The output shows the last index position of the matching string. Example 3: The example shows the string's last position of the match character for the lastIndex property. Output The output shows the last index position of the matching string. Example 4: The example shows the number function at the last position of the matching character for the lastIndex property. Output The output shows the last index position of the matching string. ConclusionThe regex lastIndex property shows the last position of the matching string before the following characters. Next TopicJavaScript RegExp {x} Quantifier |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India