日期:2014-05-17  浏览次数:20838 次

请问各位高手,如何替换字符串的从右边数的某个字符串
/yvle/uploadfile/2007-7-24/20070724150806772.jpg
/yvle/uploadfile/2007-7-24/200707241508067896.jpg

我想把最后的 "/ "     反斜杠给替换了
也就是说替换右数第一个反斜杠为 "/small/ "
谢谢


------解决方案--------------------
Dim str,leftstr,rightstr,place
str= "/yvle/uploadfile/2007-7-24/20070724150806772.jpg "
place=InStrRev(str, "/ ")
leftstr=Left(str,place-1)
rightstr=Right(str,Len(str)-place)

str=leftstr& "/small/ "&rightstr

------解决方案--------------------
<textarea id= "textarea1 " >
/yvle/uploadfile/2007-7-24/20070724150806772.jpg
/yvle/uploadfile/2007-7-24/200707241508067896.jpg
</textarea>

<script language= "vbscript ">
'vbs的写法
Dim regEx , aaa ,str
str=textarea1.value
Set regEx = New RegExp
regEx.Pattern = "(.*)/(\d+.jpg) "
regEx.IgnoreCase = true
regEx.Global = True
aaa=regEx.replace(str, "$1/small/$2 ")
MsgBox aaa


</script>