黄鹤楼崔颢的意象:在ASP中数据库字段有一组数据94,68,44,我要提取出其中的68,用什么语句操作?

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 03:27:28
就是用,分隔了3个数据,但是只要提取68这个数字,Split函数不会操作,或者还有其他方法?能详细说明吗?

dim a,b
b="94,68,44,"
a=split(b,",")
'用UBound(a)得到值为3
for i=0 to UBound(a)-1
response.write a(i)&"<br>"
next
'可以列出所有值

'当不知道,列表是不是存在68时,可以用IF语句
for i=0 to UBound(a)-1
if a(i)=68 then
response.write a(i)&"<br>"
response.write "位置为a("&i&")" '得到此数的位置
end if
next
'这样就可以了!

数组啊,

Split 函数
返回基于 0 的一维数组,其中包含指定数目的子字符串。

Split 函数返回的是数组,如果只有三组数,(如果不能确定数组,就用UBound 函数)

定义个数组a
a[1]返回的就是68

还是split容易
dim aa
aa=split(Thestr)
response.write aa(1)
就好了
别的方法麻烦

都知道要提取出什么了,为何还要提取?

看你要怎么个分离法罗!
可以使用正则表达式!分离不规则的!如
ss="98,64,75'86"
set reg= new RegExp
Reg.IgnoreCase = true
Reg.Global = true
reg.pattern = "[0-9]+"
set ms = reg.execute(ss)