How to convert "HelloWorld" to "Hello World"? The splitting has to take place based on The upper-case letters, but should exclude the first letter.
How to convert "HelloWorld" to "Hello World" ? The splitting has to take place
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This regex searches for a lowercase letter follwed by an uppercase letter and replaces them with the former, a space and the latter (effectively separating them with a space). It puts each of them in a capturing group
()in order to be able to re-use the values in the replacement string via back references ($1and$2).To find upper- and lowercase letters it uses
\p{Ll}and\p{Lu}(instead of[a-z]and[A-Z]), because it handles all upper- and lowercase letters in the Unicode standard and not just the ones in the ASCII range (this nice explanation of Unicode in regexes mostly applies to Java as well).