java过滤特殊字符
public static String StringFilter(String str) throws
PatternSyntaxException {
// 只允许字母和数字
// String regEx = "[^a-zA-Z0-9]";
// 清除掉所有特殊字符
String
regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|
{}【】‘;:”“’。,、?]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
return m.replaceAll("").trim();
}
http://sunlianwei.javaeye.com/blog/363759
相关文档:
字符串
1、获取字符串的长度
length()
2 、判断字符串的前缀或后缀与已知字符串是否相同
前缀 startsWith(String s)
后缀 endsWith(String s)
3、比较两个字符串
equals(String s)
4、把字符串转化为相应的数值
int型 Integer.parseInt(字符串)
......
/*
Function name: myGetHttpFile2
Description: 爬网页用
Input: URL 例如:http://www.126.com
Output: 字符串,网页的HTML
*/
public String myGetHttpFile2(String url){
String authentication=null;
ArrayList al=new ArrayList();
String PageURL = url;
......
import java.awt.image. * ;
import com.sun.image.codec.jpeg. * ;
public class poiReadDoc {
Image img = null;
int width = 0,height =0;
String destFile = "";
public void readImg(String fileName) throws IOException{
File _fil ......
环境安装配置
TOMCAT的配置
JAVA配置文件编写说明文档
一步一步学会配置Kjava开发环境
......