How matches() can be set to do this? I tried wildcards (".*" and ".+") look-arounds (look-behind and look-ahead) and prefix flags, and they all work with findAll, but not matches(). matches() only tries to match the whole text string, while findAll() can match substrings. I am forced to use findAll(text, regex)[0] for the 1st match and findAll(text, regex)[-1] for the last match. I know how to use indexOf along with substr or slice to to the same with string literals, but sometimes I need to use a regex with meta-character interpretation.
Please help. If there's no way, then I would really like a function to do it.
By the way. I would also like a lastIndexOf() function, using split(text0, text1)[-1] or substr(text0, -indexOf(reverse(text0), text1)) shouldn't be necessary for simple things that don't require regex. A dedicated function would be more efficient and easier to use