I have looked at this link and this link and few others but none of them seem to solve this with pure regex only (... not using replace, etc).
Input string: "Vehicle ServicesAUTOMATED GAS DISPENSER"
My desired output is: ["Vehicle Services", "AUTOMATED GAS DISPENSER"]
Here's my attempt:
var str = 'Vehicle ServicesAUTOMATED GAS DISPENSER'
console.log(str.split(/(?=[a-z][A-Z])/))
[ 'Vehicle Service', 'sAUTOMATED GAS DISPENSER' ]
I have a solution below but I don't like it because it uses an additional 'replace' method. I'm looking for a pure regex based split.
var str = 'Vehicle ServicesAUTOMATED GAS DISPENSER'
console.log(str.replace(/([a-z])(?=[A-Z])/, "$1_").split('_'))
[ 'Vehicle Services', 'AUTOMATED GAS DISPENSER' ]
Update: My requirement is simply to split the input string as specified in the post - as shown once the case flips to uppercase it remains in uppercase till the end.