Is it possible to put RegEx at the beginning of the line and start matching again?
That is why I ask. Given the line below, I would like to grab the substrings black , red , blue and green in that order, regardless of the order in which the subject appears in the string, and only if all the substrings are present in the subject line.
$str ='blue-ka93-red-kdke3-green-weifk-black'
So, for all the lines below, RegEx should capture black , red , blue and green (in that order)
'blue-ka93-red-kdke3-green-weifk-black' 'green-ka93-red-kdke3-blue-weifk-black' 'blue-ka93-black-kdke3-green-weifk-red' 'green-ka93-black-kdke3-blue-weifk-red'
I wonder if there is a way to map the capture group, and then go back to the beginning of the line and find the next capture group. I was hoping something like ^.*(?=(black))^.*(?=(red))^.*(?=(blue))^.*(?=(green)) would work but, of course, ^ and lookaheads do not behave this way.
Is it possible to build such a RegEx?
In context, I will use RegEx in PHP.
source share