Rex match a string in JS

I have few set of strings as mentioned below

/v4/users/1
/v4/users/1/vehicles/1
/v4/users
/v4/users?page=1

I would like to get users in all four cases as output using regex in Javascript

I tried below in https://www.regextester.com/

(?<=/v4/).*.(?=/[^/]*/)

It doesn’t seem to come up right.
Any help on this would be appreciated.

74 thoughts on “Rex match a string in JS”

  1. I’m really enjoying the design and layout of your website.
    It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often.
    Did you hire out a designer to create your theme?
    Outstanding work!

    Reply