当前位置: 代码迷 >> Eclipse >> 正则表达式?解决办法
  详细解决方案

正则表达式?解决办法

热度:72   发布时间:2016-04-23 01:28:33.0
正则表达式???????
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]
  相关解决方案