fork(1) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3.  
  4.  
  5. class rTest {
  6. public static void main (String[] args) {
  7.  
  8. String s = "public class hello extends jframe";
  9.  
  10. Pattern p = Pattern.compile("public\\s*class\\s+(\\S+)");
  11. Matcher m = p.matcher(s);
  12.  
  13. if (m.find()) {
  14. System.out.println("found");
  15. String className = m.group(1);
  16. System.out.println(className);
  17. }
  18.  
  19. }
  20. }
Success #stdin #stdout 0.11s 321600KB
stdin
Standard input is empty
stdout
found
hello