Skip to content

Instantly share code, notes, and snippets.

@matthung0807
Created August 2, 2017 08:43
Show Gist options
  • Save matthung0807/be7260b0fdd6a7a19ac6f284b1b9f619 to your computer and use it in GitHub Desktop.
Save matthung0807/be7260b0fdd6a7a19ac6f284b1b9f619 to your computer and use it in GitHub Desktop.
String regex1 = "^hello";
String str = new String("hello");
Pattern p1 = Pattern.compile(regex1);
System.out.println(p1.matcher(str).matches()); // true
String regex2 = "[^hello]";
Pattern p2 = Pattern.compile(regex2);
System.out.println(p2.matcher(str).matches()); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment