Java - Write code to split Camel Case String with Regex

Requirements

Write code to split Camel Case String with Regex

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String text = "AbcDefXyz";
        System.out.println(splitCamelCase(text));
    }/*from w ww. jav  a2  s.  co  m*/

    public static String splitCamelCase(String text) {
        return text.replaceAll("(?=[A-Z]+)", " ").trim();
    }
}

Related Exercise