-1

Here is my string to original:

myCamelCaseSTRINGToSPLIT

expected result:

my Camel Case STRING To SPLIT

Current regex I'm using is

(?=[A-Z])

Any help will be appriciated

Ivar
  • 6,138
  • 12
  • 49
  • 61
Sheik Althaf
  • 1,595
  • 10
  • 16
  • 3
    Possible duplicate of [Regex to split camel case](https://stackoverflow.com/questions/18379254/regex-to-split-camel-case) or a duplicate of [Split a camelCase string with regex](https://stackoverflow.com/questions/41196276/split-a-camelcase-string-with-regex) – caramba Jun 21 '18 at 07:08
  • There is no way to distinguish in "STRINGTo" where the To begins. Technically putting STRING all in caps makes it non CamelCase – Jorge.V Jun 21 '18 at 07:12

1 Answers1

2

Please use this regular expression.

yourString.replace(/([A-Z]+)/g, " $1").replace(/([A-Z][a-z])/g, " $1")

or

yourString.replace(/([A-Z]+)/g, " $1")

Live Demo with two times Replace

Live Demo with single time Replace

Hitesh Anshani
  • 1,499
  • 9
  • 19