I’ve been trying to figure this one out for a while
(something/u=another) - I just need to select ‘another’
I’ve been trying to figure this one out for a while
(something/u=another) - I just need to select ‘another’
You can do this using a positive lookbehind.
Note - In JavaScript, this was introduced in ES2018, and it doesn’t work on Firefox yet. If using Python, you’ll need to lookup the corresponding documentation.
Based on the described usage in MDN -
For example,
/(?<=Jack)Sprat/
matches “Sprat” only if it is preceded by “Jack”.
/(?<=Jack|Tom)Sprat/
matches “Sprat” only if it is preceded by “Jack” or “Tom”.
However, neither “Jack” nor “Tom” is part of the match results.
You could use \w+
to match one or more alphanumeric characters that is preceded by a special character, like =
, using /(?<==)\w+/g
-
Or, more generally, any string preceded by any non-alphanumeric character -