fork(13) download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4. class RegEx {
  5. public static void main(String[] args) {
  6. String s = "Windows Server 2008 datacenter";
  7. String r = "(?i)Win\\w*\\s*Server\\s*(2008)(?!\\sR2).*?$";
  8. Pattern p = Pattern.compile(r);
  9. Matcher m = p.matcher(s);
  10. while (m.find()) {
  11. System.out.println(m.group());
  12. }
  13. }
  14. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
Windows Server 2008 datacenter