I want to have 3 different level of hierarchies in a URL using regex

How can I get the below result set?

I have a URL: www.testurl.com/level1/level2/level3

I want 3 different outputs using Javascript Regex.

Output1: level1 Output2: level2 Output3: level3

How should I proceed with this? Thanks.