How to get all strings between slashes from URL pathname until first interrogation mark if any using regex?
For instance, I can have:
/abc/def/ghi?foo=bar → ['abc','def','ghi']
/abc/xyz → ['abc','xyz']
abc/xyz → ['abc','xyz']
abc/xyz/ → ['abc','xyz']
I tried this javascript code:
'/abc/def/ghi?foo=bar'.match(/\w+/)
But I'm only getting the abc.