日期:2014-05-16  浏览次数:20520 次

每天一问。。求个小正则
js的。。就是input

含有*1*,*2222*,等*加任意数字加*的时候,alert( "XXXXXX ")
中间那玩意
*加任意数字加*的正则是[\\*]\\d+[\\*]吧?不会用到js里> . <
谁帮俺写下啊。。感谢感谢啊~

------解决方案--------------------
<script language=javascript>
function RegexTest(yourStr)
{
return /\*\d+\*/.test(yourStr);
}

alert(RegexTest( "*2222* "));
</script>
------解决方案--------------------
<script language=javascript>
function RegexTest(yourStr)
{
/\*(\d+)\*/.test(yourStr);
return RegExp.$1
}

alert(RegexTest( "*2222* "));
</script>
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
<script language= "javascript ">
function RegexTest(){
var RegExp = /\*\d+\*/;
var oInput = document.all.bb;
if(RegExp.test(oInput.value))
alert(XXXXXX);
}
</script>
</HEAD>

<BODY>
<form name= "aa ">
<input type= "text " name= "bb ">
<input type= "button " value= "确定 " onclick= "return RegexTest() ">
</form>
</BODY>
</HTML>