`
445822357
  • 浏览: 742069 次
文章分类
社区版块
存档分类
最新评论

特殊字符处理

 
阅读更多
/**
* 去除字符串中的特殊字符
* @param string
* @return
*/
public static String FS(String str) {
// TODO Auto-generated method stub
String newstr = str.replaceAll("&", "&");
newstr = newstr.replaceAll("<", "&lt;");
newstr = newstr.replaceAll(">", "&gt;");
newstr = newstr.replaceAll("\"", "&quot;");
newstr = newstr.replaceAll("\'", "’");
return newstr;
}
/**
* 去除字符串前後空格,特殊字符
* @param string
* @return
*/
public static String getStrTrim(String str) {
// TODO Auto-generated method stub
if(str == null || "".equals(str)){
return "";
}else {
str = str.trim();
str = FS(str);
}
return str;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics