正则表达式???????
public String getSonclass(String key){
String son_class = "";
try{
conn = new connDB().getConn();
String sql = "select son_class from goods where goodsName regexp '"+key+"' or class regexp '"+key+"' or son_class regexp '"+key+"' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()){
son_class = rs.getString("son_class");
}
}
catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
this.close();
}
return son_class;
}
此类的功能是根据关键字“key”输出son_class 。 其中goodsName,class,son_class都是字段名。但是我的问题是:为什么只能根据英语单词或字母取出数据,而不能用汉字取数据? 谁能帮忙解决一下,使之可以根据"key"不论是英语还是汉语都能取出信息。
[解决办法]
[\u4e00-\u9fa50-9a-zA-Z]