vbscript就容易多了。 <% function find(x) find=false dim CardNo CardNo="436748,436745,532450,532458" for each aaa in split( CardNo,",") if x=aaa then find=true exit for end if next end function %>
<script language="VBScript"> Function CheckStr(s) Set re = New RegExp re.Pattern = "436748|436745|532450|532458" re.Global = True retval = re.Test(s) If retval Then CheckStr="OK" Else CheckStr="Wrong" End If End Function msgbox CheckStr("436748") msgbox CheckStr("436") </script>
function findingNemo(x)
{
var CardNo= new String("436748,436745,532450,532458");
var Arr=CardNo.split(",");
var D = new ActiveXObject("Scripting.Dictionary");
for(i=0;i<Arr.length;i++)
{
D.add(Arr[i],Arr[i]);
} if(D.Exists(x))
{
return true ;
}
else
{
return false ;
}
}
alert(findingNemo("1234"));
alert(findingNemo("436748"));
</SCRIPT>
function findingNemo(x)
{
if(x.match(/436748|436745|532450|532458/))
{
return true;
}else
{
return false;
} }
alert(findingNemo("1234"));
alert(findingNemo("436748"));
</SCRIPT>
<%
function find(x)
find=false
dim CardNo
CardNo="436748,436745,532450,532458"
for each aaa in split( CardNo,",")
if x=aaa then
find=true
exit for
end if
next
end function
%>
Function CheckStr(s)
Set re = New RegExp
re.Pattern = "436748|436745|532450|532458"
re.Global = True
retval = re.Test(s)
If retval Then
CheckStr="OK"
Else
CheckStr="Wrong"
End If
End Function
msgbox CheckStr("436748")
msgbox CheckStr("436")
</script>