fork(1) download
  1. import java.util.regex.*;
  2. import java.util.stream.Collectors;
  3.  
  4. class Ideone {
  5. public static void main (String[] args) throws java.lang.Exception {
  6. String s = "BByTTheWay";
  7. final Pattern p = Pattern.compile("\\p{Lu}\\p{Ll}*");
  8.  
  9. String out = p.matcher(s)
  10. .results()
  11. .map(MatchResult::group)
  12. .collect(Collectors
  13. .joining(" "))
  14. + " " + s;
  15.  
  16. System.out.println(out);
  17. }
  18. }
Success #stdin #stdout 0.14s 51012KB
stdin
Standard input is empty
stdout
B By T The Way BByTTheWay