怎样在xml中定义校验字符串的正则表达式 怎样在xml中定义校验字符串的正则表达式,例如:^\\*[0-9]+$ 校验字符串是否为数字^CM[A-Za-z0-9]+$ 校验字符串是否以CM开头请问大家怎样定义和解析? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head><title>正则表达式</title><script language="javascript">function check(str){var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.com)+/; var flag=pattern.test(str);if(flag) document.getElementById("div1").innerHTML="恭喜你!邮箱地址可以使用";else document.getElementById("div1").innerHTML="对不起!邮箱地址格式不正确";}</script></head><body ><table border="1" bordercolor="green" width="40%" align="center"><tr><th>请输入邮箱地址</th><tr><td align="center"><form name="f1"><input type="text" name="txt1" value=""><div color="red" id="div1" ></div><input type="button" name="btn1" value="检查邮箱地址" onclick="check(document.f1.txt1.value)"></form></td></tr></table></body></html>这是检查邮箱是否正确的代码,楼主看一下,希望对你有帮助。 lost_guy_in_scut 谢谢你的指点。要是用html实现的话,你的代码是可以的。但我现在想用xml文件。 可以考虑 XPath 2.0 提供的 fn:matches XML 的验证建议使用 Schema 来做,而不是正则表达式。 看程序的好习惯,汇集一下大家的意见 ~1(1的补码是多少) 标记接口(Mark Interface)的作用 java试题 如何切这割字符串 java里面这样的工具吗 请问java怎么调用C的可执行程序 为什么用while(true)语句? 急,急,急! 各位大瞎侠请问哪有Jbuilder7中文版下载? 那些是java经典网站?有源程序下载的,谢谢各位!◎!!! 为什么我写的JFrame只能在main方法里new,不能在按钮事件里new 正则表达式如何替换匹配的一部分字符串
<html>
<head>
<title>正则表达式</title>
<script language="javascript">
function check(str)
{
var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.com)+/;
var flag=pattern.test(str);
if(flag)
document.getElementById("div1").innerHTML="恭喜你!邮箱地址可以使用";
else
document.getElementById("div1").innerHTML="对不起!邮箱地址格式不正确";
}
</script>
</head>
<body >
<table border="1" bordercolor="green" width="40%" align="center">
<tr>
<th>请输入邮箱地址</th>
<tr>
<td align="center">
<form name="f1">
<input type="text" name="txt1" value=""><div color="red" id="div1" ></div>
<input type="button" name="btn1" value="检查邮箱地址" onclick="check(document.f1.txt1.value)">
</form>
</td>
</tr>
</table>
</body>
</html>
这是检查邮箱是否正确的代码,楼主看一下,希望对你有帮助。
但我现在想用xml文件。