Matching two path elements using javascript regex to make the right hand side greedy
I am trying to match this. /1234/5678 /1234 Into A and B, where the B is optional using this regular expression. /.*/(?<A>d+)(/(?<B>.+?))?$/.exec("/1234/5678").groups; I want A=1234, and B=5678 when the path contains two parts, and when there's only one part, then…