fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // Open the input stream.
  13. //Scanner sc = new Scanner(System.in);
  14.  
  15. // Put your code here.
  16. // For sample (Read the line)
  17. //String s = sc.nextLine();
  18. String s = "This string has (len) characters.";
  19. String d = String.valueOf(s.length());
  20.  
  21. int lengthWithout = s.replaceAll("[(][a-zA-Z]*[)]", "").length();
  22. //int lengthLengthWithout = String.valueOf(lengthWithout)
  23.  
  24. String string = s.replaceAll("[(][a-zA-Z]*[)]", String.valueOf(lengthWithout + String.valueOf(lengthWithout).length()));
  25.  
  26. System.out.println(string);
  27. }
  28. }
Success #stdin #stdout 0.08s 27816KB
stdin
Standard input is empty
stdout
This string has 30 characters.