fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.regex.*;
  5. import java.lang.*;
  6. import java.io.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. // your code goes here
  14. String sentence = "i love eating pie hellooosss goodiieess";
  15. //Scanner input = new Scanner(System.in);
  16.  
  17. // System.out.println("Enter a sentence: ");
  18. //sentence = input.nextLine();
  19. //sentence = sentence.replaceAll("(?=\\b\\w{6,}\\b)[a-z]", "$1".toUpperCase());
  20. Pattern p = Pattern.compile("(?=\\b\\w{6,}\\b)([a-z])\\w+");
  21. Matcher m = p.matcher(sentence);
  22. while (m.find()){
  23. m.appendReplacement(s, m.group(1).toUpperCase() + m.group(0).substring(1));
  24. }
  25. System.out.println(s.toString());
  26. }
  27. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
i love Eating pie Hellooosss Goodiieess