I'm currently working on extracting the second occurrence in a regular expression string.
Let's consider a domain name:
https://regexrocks.com/my/socks/off
We want to replace everything after .com
$this.val($this.val().replace(/(([^.]*.)[^]?.[^\/]?)/, ''));
The regex being used is:
(([^.]*.)[^]?.[^/]?)
This will replace the first match with the second: /my/socks/off
.
https://regex101.com/r/46BIqG/1
Is there a way to capture the second match instead?