I am trying to do something fairly simple however I have not worked extensively with Regex before.
I am trying to extract some strings out of another string.
I have the string 'value/:id/:foo/:bar'
I would like to extract each string after the colon and before slash eg:
let s = 'value/:id/:foo/:bar';
let r = new RegExp(/MAGIC HERE/);
// result r.exec(s)
I have been trying for an hour or so on this website: https://regex101.com/ but can only get as close as this:
:([a-z]+)
I also tried playing with these examples but couldn't get anywhere:
Regex match everything after question mark?
How do you access the matched groups in a JavaScript regular expression?
I want to be able to extract these parameters infinitely if possible.
My intended result is to get an array of each of the parameters.
group 1 - id
group 2 - foo
group 3 - bar
Please consider explaining the regex that can help with this I want to understand how groups are formed in the regex.