首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

正则表达式?解决办法

2013-04-02 
正则表达式???????public String getSonclass(String key){String son_class try{conn new connDB(

正则表达式???????
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]

热点排行