求个正则表达式…………………… str = "http:\/\/www.xxx.com\/123456" 字符串求个能匹配的正则表达式。123456代表网址后面的一个内容,可以(.*?)表示,主要是前面部分。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /http://www.\w*.com/ /http://www.\w*.com/意思是说,\/\/这些不用去管他?按照正常的网址直接匹配?注:http:\/\/www.xxx.com\/ 这个就已经是等待匹配的字符串了,不是表达式。想半天不知道如何转译符号…… /http://((.*)/(.*))/批配后,alert下数组就知道了 var reg=RegExp("(^[a-zA-Z:\.\/])(\.*$)","ig");var d="http://www.xxx.com/123456";alert(reg.test(d)); i have done it by myself,but thanks all the same!give the points and ending the problem. 是不是匹配红色部分 http://www.xxx.com/123456, 如下是匹配红色部分的<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title></head><script language="javascript" type="text/javascript">function doCHK(){var reg=RegExp(/(http:\/\/www\.)(\w*)\.com\/(.*$)/ig);var url; //="http://www.xxx.com/123456";url=document.getElementById("content1").value;if(reg.test(url)) alert("匹配");else alert("不匹配");}</script><body><p>正则匹配问题<br><input name="content1" type="text" id="content1" value="http://www.xxx.com/123456" size="60"><input name="BTN01" value="Test" type="button" onClick="javascript:doCHK();"></p></body></html> 还是求助导航变换背景问题 再问正则表达式。 100分求助跨域刷新父页面问题 js怎样统计一段字符中某个单词或某个标点符号(如:China或.点号)的个数 登陆JS在IE7下可以正常运行.IE6和maxthon失效的问题 很复杂的正则表达式,要考虑几种条件 createElement生成的对象,用什么方法取得? 如何去掉select下拉框的滚动条? 打印时如何去掉页面底部的路径和顶端的页码编号 在页面间直接进行修改文本内容??。。。 js 怎么给create控件加上鼠标事件? |zyciis| 如何在Jquery Ajax中的ajaxStart取得当前Ajax提交的url 谢谢
批配后,alert下数组就知道了
var reg=RegExp("(^[a-zA-Z:\.\/])(\.*$)","ig");
var d="http://www.xxx.com/123456";
alert(reg.test(d));
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<script language="javascript" type="text/javascript">
function doCHK()
{
var reg=RegExp(/(http:\/\/www\.)(\w*)\.com\/(.*$)/ig);
var url; //="http://www.xxx.com/123456";
url=document.getElementById("content1").value;
if(reg.test(url))
alert("匹配");
else
alert("不匹配");
}
</script>
<body>
<p>
正则匹配问题<br>
<input name="content1" type="text" id="content1" value="http://www.xxx.com/123456" size="60">
<input name="BTN01" value="Test" type="button" onClick="javascript:doCHK();">
</p>
</body>
</html>