zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

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

ASP 字符串 Function 空格 去掉 连续 回车
2023-06-13 09:14:07 时间

复制代码代码如下:


"去掉字符串头尾的连续的回车和空格
functiontrimVBcrlf(str)
trimVBcrlf=rtrimVBcrlf(ltrimVBcrlf(str))
endfunction

"去掉字符串开头的连续的回车和空格
functionltrimVBcrlf(str)
dimpos,isBlankChar
pos=1
isBlankChar=true
whileisBlankChar
ifmid(str,pos,1)=""then
pos=pos+1
elseifmid(str,pos,2)=VBcrlfthen
pos=pos+2
else
isBlankChar=false
endif
wend
ltrimVBcrlf=right(str,len(str)-pos+1)
endfunction

"去掉字符串末尾的连续的回车和空格
functionrtrimVBcrlf(str)
dimpos,isBlankChar
pos=len(str)
isBlankChar=true
whileisBlankCharandpos>=2
ifmid(str,pos,1)=""then
pos=pos-1
elseifmid(str,pos-1,2)=VBcrlfthen
pos=pos-2
else
isBlankChar=false
endif
wend
rtrimVBcrlf=rtrim(left(str,pos))
endfunction