当前位置:首页 > 技术前沿 > 正文内容

ASP去除字符串头尾连续回车和空格的函数

狂龙16年前 (2010-09-20)技术前沿7

挺不错的几个小函数,收藏一下。

'去掉字符串头尾的连续的回车和空格
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

相关文章

asp的日期转换星座函数

  '日期转换星座函数,参数是日期型 function astro(birth) astro="" if birth="" or...

解决ASP网站gb2312和utf-8乱码问题

经常做网站的人都知道,在同一个站点里使用不同编码的页面会产生乱码,比较常见的就是gb2312和Utf-8。当出现这种情况的时候也很好解决,我们做ASP网站时,一般都会用到conn.asp来连接数据库,...

asp判断数字奇偶数

很不错的一段代码,收藏下 function isEven(num) if not isNumeric(num) then'先判断是否为数字 isEven="这不是一个数字啊...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。