fork(7) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.*;
  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. String href = "../../tool/model/toolingValidationReport.php?fileName="
  14. + "test-testing-types.txt&fileSize=18380&validationReport=[{\"reso"
  15. + "urceUri\":\"file:\\/home\\/admin\\/test-modeling\\/apache-tomca"
  16. + "t-7.0.70\\/temp\\/IOS\\/filetest-file-files.txt#\\/\\/@statemen"
  17. + "ts.12\\/@typeList.0\\/@enumLiterals.11\",\"severity\":\"WARNING"
  18. + "\",\"lineNumber\":333,\"column\":9,\"offset\":7780,\"length\":2"
  19. + "4,\"message\":\"Enum name should be less than 20 characters\"}]"
  20. + " target=\"";
  21.  
  22. Pattern validationReportPattern = Pattern.compile("(\\[\\{.*}])");
  23. Matcher validationReportMatcher = validationReportPattern.matcher(href);
  24.  
  25.  
  26. if (validationReportMatcher.find())
  27. {
  28. String validationReport = validationReportMatcher.group(1);
  29. System.out.println ("Match: " + validationReport);
  30. }
  31. else
  32. {
  33. System.out.println ("No match");
  34. }
  35. }
  36. }
Success #stdin #stdout 0.08s 2841600KB
stdin
Standard input is empty
stdout
Match: [{"resourceUri":"file:\/home\/admin\/test-modeling\/apache-tomcat-7.0.70\/temp\/IOS\/filetest-file-files.txt#\/\/@statements.12\/@typeList.0\/@enumLiterals.11","severity":"WARNING","lineNumber":333,"column":9,"offset":7780,"length":24,"message":"Enum name should be less than 20 characters"}]