I have a string which looks like below
str = "I have candy='4' and ice cream = 'vanilla'"
I want to get terms to the left side of latest = and the terms should be fetched until the occurrence of another =.
So my string should be
leftOfEqual = "'4' and ice cream"
Another example
str = "I have candy='4' and ice cream = 'vanilla' and house='big'"
leftOfEqual = "'vanilla' and house"
This is my regex currently
leftOfEqual = str.match(/\S+(?= *=)/)[0]
But it looks at the first = and gives me only the immediate word to the left.
How can I do this?
NOTE: In case there is no presence = to the left of latest =, I should get the complete string till the beginning then.


iceinice creamwhich is left of the equals? Isanda key word to split by?.*=(.*)=.*and use$1for replacement.=till the occurrence of another=, that piece of string should be fetched..split('=')?