加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP消除字符串头尾连续回车和空格的Function

发布时间:2023-05-19 13:10:43 所属栏目:Asp教程 来源:
导读:ASP消除字符串头尾连续回车和空格的Function:代码如下:'去掉字符串头尾的连续的回车和空格function trimVBcrlf(str)trimVBcrlf=rtrimVBcrlf(ltrimVBcrlf(str))end function'去掉字符串开头的连续的回车和空

ASP消除字符串头尾连续回车和空格的Function:

代码如下:

'去掉字符串头尾的连续的回车和空格

function trimVBcrlf(str)

trimVBcrlf=rtrimVBcrlf(ltrimVBcrlf(str))

end function

'去掉字符串开头的连续的回车和空格

function ltrimVBcrlf(str)

dim pos,isBlankChar

pos=1

isBlankChar=true

while isBlankChar

if mid(str,pos,1)=" " then

pos=pos+1

elseif mid(str,pos,2)=VBcrlf then

pos=pos+2

else

isBlankChar=false

end if

wend

ltrimVBcrlf=right(str,len(str)-pos+1)

end function

'去掉字符串末尾的连续的回车和空格

function rtrimVBcrlf(str)

dim pos,isBlankChar

pos=len(str)

isBlankChar=true

while isBlankChar and pos>=2

if mid(str,pos,1)=" " then

pos=pos-1

elseif mid(str,pos-1,2)=VBcrlf then

pos=pos-2

else

isBlankChar=false

end if

wend

rtrimVBcrlf=rtrim(left(str,pos))

end function

(编辑:银川站长网)

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

    推荐文章