fork(21) 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 = " hello there I like regex!";
  9.  
  10. Pattern p = Pattern.compile("^\\s+[a-zA-Z\\s]+[.?!]$");
  11. Matcher m = p.matcher(s);
  12.  
  13. if (m.matches()) {
  14. System.out.println("hurray!");
  15. }
  16.  
  17. }
  18. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
hurray!