Skip to content

Instantly share code, notes, and snippets.

@matthung0807
Created July 31, 2017 07:16
Show Gist options
  • Save matthung0807/553c11c7b5eb9f59e288754cf265dff6 to your computer and use it in GitHub Desktop.
Save matthung0807/553c11c7b5eb9f59e288754cf265dff6 to your computer and use it in GitHub Desktop.
Pattern p = Pattern.compile("^he"); // Pattern.compile()的參數字串為正規表示式
Matcher m = p.matcher("hello world"); // matcher()的參數為要查詢的字串
System.out.println(m.find()); // 若查詢的字串的子字串符合正規表示式的規則,Matcher.find()回傳true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment