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

replace函数,把一个字符串a里的":"替换为"-",但第一个":"不替换,后两个替换,语句怎么写
replace函数,把一个字符串a里的 ": "替换为 "- ",但第一个 ": "不替换,后两个替换,语句怎么写


------解决方案--------------------
如果不用正则:
<script language= "vbscript ">
str= "fafa:012:34:56:789: "
document.write (left(str, instr(str, ": ")) & replace(mid(str, instr(str, ": ") + 1, len(str) - instr(str, ": ") + 1), ": ", " "))
</script>

------解决方案--------------------
Response.Write Replace( "XXpXXPXXp ", "p ", "Y ", 1, 2, 0)
从一开始替换
替换两次
执行二进制比较。
------解决方案--------------------
str= "ookjllkjj:jjklkj:4561213:55:jhj "
str1=left(str,instrrev(str, ": ",instrrev(str, ": ")-1)-1)
&replace(str, ": ", "- ",instrrev(str, ": ",instrrev(str, ": ")-1))
response.write (str1)
------解决方案--------------------
<%
Dim Strng, Key, NKey, Num
Strng = "XXpXXPXXp " : Key = "p " : Nkey = "Y " : Num = Instr(Strng, Key)
Response.Write Left(Strng, Num) & Replace(Strng, Key, Nkey, Num + 1, 2, 1)
%>