//提取
public void regExp(){
String hqlString = "select * from User where username = xuly and password = 1111";
Pattern pattern = Pattern.compile("(username\\s=\\s\\S*)");
Matcher matcher = pattern.matcher(hqlString);
while (matcher.find()) {
System.out.println(matcher.group(1));
}
}
//替换
@Test
public void replace(){
String hqlString = "select * from User where username = ? and password = ?";
Pattern pattern = Pattern.compile("\\?");
Matcher matcher = pattern.matcher(hqlString);
System.out.println(matcher.replaceAll("values"));
}