<html>
<head>
<title> New Document </title>
<script language="javascript">
function cc(){
var s="12222北京";
var s2="12222北京";
var s3=" 1 2 2 2 2 北京";
//取数字
s=s.replace(/[^\d]*/ig,"");
alert(s);
//取中文
s2=s2.replace(/[\d]*/ig,"");
alert(s2);
//去掉所以空格
s3=s3.replace(/\s/ig,"");
alert(s3);
}
</script>
</head>
<body>
<input type="button" value="提交" onclick="cc();">
</body>
</html>
取字符串中的数字,汉字,去掉字符串空格
最新推荐文章于 2020-12-04 11:09:18 发布