Skip to content

Instantly share code, notes, and snippets.

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
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
String regex = "^he";
String s = new String("hello world");
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(s);
System.out.println(m.find()); // => false
System.out.println(m.find()); // => true
String regex = "^he";
String s = new String("hello world");
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(s);
System.out.println(m.matches()); // => false
System.out.println(m.find()); // => true
Pattern p = Pattern.compile("^he"); // Pattern.compile()的參數字串為正規表示式
Matcher m = p.matcher("hello world"); // matcher()的參數為要查詢的字串
System.out.println(m.find()); // 若查詢的字串的子字串符合正規表示式的規則,Matcher.find()回傳true
嚴重: Servlet.service() for servlet [dispatcher] in context with path [/moneynote] threw exception [Request processing failed; nested exception is org.springframework.dao.DuplicateKeyException: StatementCallback; SQL [INSERT INTO tb_catg VALUES('測試類別001',NOW(),NOW())]; Duplicate entry '測試類別001' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '測試類別001' for key 'PRIMARY'] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Duplicate entry '測試類別001' for key 'PRIMARY'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
嚴重: Servlet.service() for servlet [dispatcher] in context with path [/moneynote] threw exception [Request processing failed; nested exception is org.springframework.dao.DuplicateKeyException: StatementCallback; SQL [INSERT INTO tb_catg VALUES('測試類別001' ,NOW(),NOW())]; Duplicate entry '測試類別001' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '測試類別001' for key 'PRIMARY'] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '測試類別001' for key 'PRIMARY'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
$("input").click(function(){
console.log($(this).val());
});
<html>
<head>
</head>
<body>
<input type="button" value="A"/>
<input type="button" value="B"/>
<input type="button" value="C"/>
</body>
</html>