加入收藏 | 设为首页 | 会员中心 | 我要投稿 南平站长网 (https://www.0599zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

ASP中Split分割字符串函数的实例用法

发布时间:2016-12-07 15:25:19 所属栏目:PHP教程 来源:站长网
导读:ASP中Split函数的用法 分割截取字符串 看几个例子就能理解了 复制代码 代码如下: mystr="1,2,3,4,5" mystr=split(mystr,",") for i=0 to ubound(mystr) response.write mystr(i) nextnbsp; '返回值为123456 mystr="xlei.net/http/student/x/index.asp" mys

ASP中Split函数的用法
分割截取字符串
看几个例子就能理解了

复制代码 代码如下:
mystr="1,2,3,4,5"
mystr=split(mystr,",")
for i=0 to ubound(mystr)
response.write mystr(i)
nextnbsp;
'返回值为123456

mystr="xlei.net/http/student/x/index.asp"
mystr=split(mystr,"/http/student")
for i=0 to ubound(mystr)
response.write mystr(i)
nextnbsp;
'返回值为xlei.net/x/index.asp

mystr="1批在2批在3批在4批是在5批在"
mystr=split(mystr,"批在")
for i=0 to ubound(mystr)
response.write mystr(i)
nextnbsp;
'返回值为1234批是在56


描述
返回基于 0 的一维数组,其中包含指定数目的子字符串。
语法
Split(expression[, delimiter[, count[, start]]])
Split 函数的语法有以下参数:

参数 描述
expression 必选。字符串表达式,包含子字符串和分隔符。如果 expression 为零长度字符串,Split 返回空数组,即不包含元素和数据的数组。
delimiter 可选。用于标识子字符串界限的字符。如果省略,使用空格 ("") 作为分隔符。如果 delimiter 为零长度字符串,则返回包含整个 expression 字符串的单元素数组。
count 可选。被返回的子字符串数目,-1 指示返回所有子字符串。
compare 可选。指示在计算子字符串时使用的比较类型的数值。有关数值,请参阅“设置”部分。

设置
compare 参数可以有以下值:
常数 值 描述
vbBinaryCompare 0 执行二进制比较。
vbTextCompare 1 执行文本比较。
vbDatabaseCompare 2 执行基于数据库(在此数据库中执行比较)中包含的信息的比较。

引用来自 asp端验证是否包含非法字符

复制代码 代码如下:
username=replace(trim(request.form("username")),"'","''")
password=replace(trim(request.form("password")),"'","''")

if instr(username,"%") or instr(username,"#") or instr(username,"?") or instr(username,"|") then
nbsp;nbsp;nbsp;nbsp; response.write "lt;script. language=javascriptgt;alert('您的姓名含有非法字符!');history.back()lt;/scriptgt;"
nbsp;nbsp;nbsp;nbsp; response.end
nbsp;nbsp;nbsp;nbsp; end if
if instr(password,"%") or instr(password,"#") or instr(password,"?") or instr(password,"|") then
nbsp;nbsp;nbsp;nbsp; response.write "lt;script. language=javascriptgt;alert('您的密码含有非法字符!');history.back()lt;/scriptgt;"
response.end
end if

(编辑:南平站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读