fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.regex.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. String str = "((created_date{[1976-03-06T23:59:59.999Z TO *]}|1))";
  11. String patt = "\\(\\(([^{]+)\\{\\[([^ ]+) TO ([^]]+)]}\\|([01])\\)\\)";
  12. Pattern p = Pattern.compile(patt);
  13. Matcher m = p.matcher(str);
  14. if (m.matches()) {
  15. System.out.println(m.group(1));
  16. System.out.println(m.group(2));
  17. System.out.println(m.group(3));
  18. System.out.println(m.group(4));
  19. }
  20. }
  21. }
Success #stdin #stdout 0.04s 2184192KB
stdin
Standard input is empty
stdout
created_date
1976-03-06T23:59:59.999Z
*
1