编程论坛
注册
登录
编程论坛
→
ASP技术论坛
怎么判断内容里有没有符号“-”
hmhz
发布于 2007-08-16 15:02, 933 次点击
怎么判断内容里有没有符号“-”
11 回复
#2
qhscqb
2007-08-16 15:22
dim str
str="abcdkdk-sskdk-dd"
for i=1 to 10
if mid(str,i,1)="-" then
document.write ("有-号!")
end if
next
#3
qhscqb
2007-08-16 15:23
dim str
str="abcdkdk-sskdk-dd"
for i=1 to len(str)
if mid(str,i,1)="-" then
document.write ("有-号!")
end if
next
#4
ayue222
2007-08-16 15:25
if instr(string,"-")>0 then response.write ("有-号!")
#5
hmhz
2007-08-16 15:29
不错,我怎么没想到这样来写呢
#6
qhscqb
2007-08-16 15:39
实现的具体方法不同
#7
hmhz
2007-08-16 15:45
if instr(string,"-")<>0 then
这样判断最贴切
[此贴子已经被作者于2007-8-16 15:46:03编辑过]
#8
ayue222
2007-08-16 15:47
我这个是ASP中的方法 ...他们的是JS中的方法 ...
#9
hmhz
2007-08-16 15:54
不,asp也可以这样使用的
<%
for i=1 to len(str)
if mid(str,i,1)="-" then
document.write ("有-号!")
end if
next
%>
#10
ayue222
2007-08-16 16:00
...偶从没有这样用过 ...直接instr多简单撒 ...
#11
qhscqb
2007-08-16 16:11
呵呵!
mid函数很有用的。
#12
ayue222
2007-08-16 16:13
mid是截取字符串撒 .... 当然这里这样判断也行 ...不过..如果这个字符串很长的话 ..用mid的效率就明显不如instr了 ...
1