I’m looking for a way to grab the following data from this string
DON'T FLOP - Rap Battle - Illmaculate Vs Tony D
DON'T FLOP - Rap Battle - $var1 Vs $var2
so I can just end up with $var3 = $var1 Vs $var2
The issue is that the opponents name can contain more than one word, whilst I can just go till the end of the sentence for the opponent to the right of the vs, I’ve got no way to delimit the start of the opponents name, do I?
How can I do the check from the white space after the -, stop at vs and start again for $var2 till the end of the sentence?
A non-greedy capture group
(.+?)to the left ofVs, following the-and space should grab the first name. As long as you always have space following the-this should work fine.\s+allow for multiple spaces if necessary.