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. String s = "5 = cell: 1 [{1.042} {10, 2.387, 2.488} ].";
  13. // The first occurrence of [{, +2 to skip to the following text.
  14. int start = s.indexOf("[{") + 2;
  15.  
  16. // The first occurrence of } after the [{.
  17. int end = s.indexOf("}", start);
  18.  
  19. // Extract the substring between these indexes.
  20. String sub = s.substring(start, end);
  21.  
  22. System.out.println(sub);
  23. }
  24. }
Success #stdin #stdout 0.04s 842240KB
stdin
Standard input is empty
stdout
1.042