How to split a string by uppercase and lowercase in JavaScript?

javascript, regex

Solution

`([A-Z]+|[a-z]+)`. Match all upper case, or all lower case multiple times in capturing groups. Give this a try here: https://regex101.com/r/bC8gO3/1

Problem

Is it possible to split Strings in JavaScript by case such that the following string below (myString) would be converted into the array (myArray) below: ``` var myString = "HOWtoDOthis"; var myArray = ["HOW", "to", "DO", "this"]; ``` I have tried the regex below, but it only splits for camelCase: ``` .match(/[A-Z]*[^A-Z]+/g); ```

Original source

Related problems