当前位置: 移动技术网 > IT编程>开发语言>.net > ASP去掉字符串头尾连续回车和空格

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

2018年02月08日  | 移动技术网IT编程  | 我要评论
在处理字符转的时候一般都会遇到去除空格和去除回车的问题,不然可能会导致程序一些报错。   function trimVBcrlf(str) trimVBcrlf=r
在处理字符转的时候一般都会遇到去除空格和去除回车的问题,不然可能会导致程序一些报错。
 
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 www.2cto.com
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  

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网