PROPERTY: RegExp::lastParen
RegExp.lastParen
This property contains the last matched parenthesized substring (if any), and as a static
property is always refered to using RegExp.lastParen. For example, the following code
uses a regular expression containing three parenthesized substrings to search for a match
in the string "the fisherman's tale". After successfully matching the substring 'sherm', the
lastParen property will hold the value 'r', which is the match made by the last
parenthesized substring (any consonant).
Code:
rexp = /([^aeiou\s]){2}([aeiou])+([^aeiou\s]){2}/
rexp("the fisherman's tale")
Output:
r
|