(com.nhncorp.lucy.db.sql.ManagedDataSource:677) executing ibatis statement 'com.nhn.sapphire.cache.selectOnlyInfo'
我想把com.nhn.sapphire.cache.selectOnlyInfo取出来。
这样写居然不对。
\'((^[\'])+?)\'
------解决方案--------------------
String exe = "(com.nhncorp.lucy.db.sql.ManagedDataSource:677) executing ibatis statement 'com.nhn.sapphire.cache.selectOnlyInfo'";
String reg = "(?<=')[^']*";
Matcher mer = Pattern.compile(reg).matcher(exe);
if (mer.find()) {
System.out.println(mer.group());
}
------解决方案--------------------
当然了,也可以使用懒惰量词 *? 改成这样:
- Java code
// String regex = "'([^']*)'";String regex = "'(.*?)'";Pattern pattern = Pattern.compile(regex);Matcher matcher = pattern.matcher(str);while (matcher.find()) { System.out.println(matcher.group(1));}