Skip to content

Instantly share code, notes, and snippets.

@matthung0807
Created August 2, 2017 09:00
Show Gist options
  • Save matthung0807/58ec9623eb108bfda4b52e487350cbc9 to your computer and use it in GitHub Desktop.
Save matthung0807/58ec9623eb108bfda4b52e487350cbc9 to your computer and use it in GitHub Desktop.
String str1 = new String("hello world");
String str2 = new String("world hello");
String str3 = new String("the world wryyyy");
String regex = "^(?!.*hello)";
Pattern p = Pattern.compile(regex);
System.out.println(p.matcher(str1).find()); // false
System.out.println(p.matcher(str2).find()); // false
System.out.println(p.matcher(str3).find()); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment