public class InputString{ public static void main(String[] args){ String s="a ee "; System.out.println(s.replaceAll("\\s","")); } }
function check_data() { if (document.form1.cname.value=="") { alert("查询条件不可为空"); document.form1.name.focus(); return false; } var re = new RegExp(/^\[ \s]*$/); var a = document.form1.name.test(re); alert(a) if(a){ return false; }else{ return true; }
}为什么输入空格的时候还是提交了啊???
import java.util.regex.*; public class TestToDel { public static void main(String[] args) { String a = " "; Pattern pa = Pattern.compile("^\\s+$"); Matcher ma = pa.matcher(a); if(ma.find()) System.out.println("false"); } }你可以任意改变a试验一下! 它只要包含字母就不会返回false了.
很多地方都要判断输入是否为空、输入数据类型、输入字符长度....
public static void main(String[] args){
String s="a ee ";
System.out.println(s.replaceAll("\\s",""));
}
}
{
if (document.form1.cname.value=="")
{
alert("查询条件不可为空");
document.form1.name.focus();
return false;
}
var re = new RegExp(/^\[ \s]*$/);
var a = document.form1.name.test(re);
alert(a)
if(a){
return false;
}else{
return true;
}
}为什么输入空格的时候还是提交了啊???
import java.util.regex.*;
public class TestToDel {
public static void main(String[] args) {
String a = " ";
Pattern pa = Pattern.compile("^\\s+$");
Matcher ma = pa.matcher(a);
if(ma.find())
System.out.println("false");
}
}你可以任意改变a试验一下! 它只要包含字母就不会返回false了.