ASP去掉字符串頭尾連續回車和空格

在處理字符轉的時候通常都會遇到去除空格和去除回車的問題,否則可能會致使程序一些報錯。 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 中國數據 q:800013911轉1018
相關文章
相關標籤/搜索