Split by Caps in Javascript,

Posted by user1294188 on Stack Overflow See other posts from Stack Overflow or by user1294188
Published on 2012-04-08T17:12:20Z Indexed on 2012/04/08 17:29 UTC
Read the original article Hit count: 167

Filed under:
|

I am trying to split up a string by caps using Javascript,

Examples of what Im trying to do:

"HiMyNameIsBob"  ->   "Hi My Name Is Bob"
"GreetingsFriends" -> "Greetings Friends"

I am aware of the str.split() function, however I am not sure how to make this function work with capital letters.

I've tried:

str.split("(?=\\p{Upper})")

Unfortunately that doesn't work, any help would be great.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex