I'm working with regex in order to obtain a word from a string. I have a css class which has multiple classes like: "foo foo-bar foo-bar2 baz-foo" and I want to extract the word after every "foo-" string. In this case will be an array of two elements: "bar" and "bar2".
Does anyone know any way to do it using regex or, even with a javascript function?
I tried things like: /foo-\w+/g or /foo-\w+-\w+/g but I'm not an expert of regex.
Thank you in advance,
data-*attributes?foo-(\S+), grab the string inside group index 1.