fork(4) download
  1. import java.util.regex.*;
  2.  
  3. class Main
  4. {
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. String s = "hello 'cool1' word! 'cool2'";
  8. Pattern pattern = Pattern.compile("'([^']*)'");
  9. Matcher matcher = pattern.matcher(s);
  10. if (matcher.find()) {
  11. System.out.println(matcher.group(1));
  12. }
  13. }
  14. }
Success #stdin #stdout 0.03s 245632KB
stdin
Standard input is empty
stdout
cool1