特殊字符的提交 JS处理

function filter(str){
    str = str.replace(/\+/g,"%2B");
    str = str.replace(/\&/g,"%26");
    str = str.replace(/\,/g,"%2C");
    
    str = str.replace(/\//g,"%2F");
    str = str.replace(/\?/g,"%3F");
    str = str.replace(/\:/g,"%3A");
    
    str = str.replace(/\@/g,"%40");
    str = str.replace(/\=/g,"%3D");
    str = str.replace(/\$/g,"%24");
    
    str = str.replace(/\#/g,"%23");
    str = str.replace(/\%/g,"%25");
    str = str.replace(/\ /g,"%20");
    return str;
}
	private String doFilter(String name){
		name=name.replace("%2B", "+");
		name=name.replace("%26", "&");
		name=name.replace("%2C", ",");
		
		name=name.replace("%2F", "/");
		name=name.replace("%3F", "?");
		name=name.replace("%3A", ":");
		
		name=name.replace("%40", "@");
		name=name.replace("%3D", "=");
		name=name.replace("%24", "$");
		
		name=name.replace("%23", "#");
		name=name.replace("%25", "%");
		name=name.replace("%20", " ");
		return name;
	}


你可能感兴趣的:(特殊字符)