/** 给content的img添加a
* @param content
* @return
*/
private String updateContent(String content) {
StringBuffer result = new StringBuffer();
String temp = "";
int begin = content.toLowerCase().indexOf("<img");
while(begin != -1) {
result.append(content.substring(0, begin));
temp = content.substring(begin);
int imgSrcBegin = temp.toLowerCase().indexOf("src=") + 5;
String imgUrl = temp.substring(imgSrcBegin, imgSrcBegin + 50);
imgUrl = imgUrl.toLowerCase().replace("/s/", "/");
imgUrl = "<a rel=\"example_group\" href=\""+imgUrl+"\" >";
result.append(imgUrl);
int imgEnd = temp.toLowerCase().indexOf("/>") + 2;
String img = temp.substring(0, imgEnd);
result.append(img);
result.append("</a>");content = temp.substring(imgEnd, temp.length());
begin = content.toLowerCase().indexOf("<img");
if(begin == -1)
result.append(content);
}return result.toString();
}
这个应该是.NET版本用的吧 想在ASP实现这样的功能 这个函数应该怎么修改啊》
请高手帮忙.NETASPStringstringbuffer
解决方案 »
- 求助。多页面之间,大批量数据传递,如何实现?
- 如何在点击按钮时,不立即触发事件!
- 客户端如何调用.ocx里面的函数
- 家里机器怎么做个临时的服务器
- 如何理解“把xml文件以流的方式直接POST到我们系统的某个http接口中”然后解析,入库???
- 在线等:jmail4.3 收邮件。。为什么报This function is not included in this version of jmail????? 在线等
- asp.net中制作框架网页 怎样在框架整体刷新的情况下 子框架里面的页面仍然保持状态?
- Frame3set.htm总是提示Left2.aspx第一行<%...%>出错,请问各位专家如何解决?焦急等待!
- 请问ASP。NET支持哪些数据库!?
- 救急!请问哪里有CrystalReport的书以及源码?
- 如何做OJ的排队器
- 在ASP.NET服务端给TextBox赋值,有相当于 HttpUtility.HtmlEncode的功能?
StringBuilder用来字符串拼接
比如
result.append(img);
result.append("</a>");
=>
result = result & img
result = result & "</a>"IndexOf对应Instr()
ToLowCase对应LCase()
SubString对应Mid()别的你应该都会。
版主麻烦帮我看下 我转化的代码 那边还有问题使用的时候提示类型错误<%
function updateContent(content)
dim result
dim temp:temp = ""
int begin = Instr(LCase(content),"<img")
while begin <> -1
result=result & Mid(content,0, begin)
temp = Mid(content,begin)
int imgSrcBegin = Instr(LCase(temp),"src=") + 5
dim imgUrl:imgUrl = Mid(temp,imgSrcBegin, imgSrcBegin + 50)
imgUrl = replace(LCase(imgUrl),"/s/", "/")
imgUrl = "<a href=\""&imgUrl&"\" >"
result=result&imgUrl
int imgEnd = Instr(LCase(temp),"/>") + 2
String img = Mid(temp,0, imgEnd)
result=result & img
result=result & "</a>"
content = Mid(temp,imgEnd, len(temp))
begin = Instr(LCase(content),"<img")
if begin = -1 then result=result&content
wend
updateContent=result
end function
%>
请版主榜我看下 我转化的代码 那边还有问题?
<%
function updateContent(content)
dim result
dim temp:temp = ""
int begin = Instr(LCase(content),"<img")
while begin <> -1
result=result & Mid(content,0, begin)
temp = Mid(content,begin)
int imgSrcBegin = Instr(LCase(temp),"src=") + 5
dim imgUrl:imgUrl = Mid(temp,imgSrcBegin, imgSrcBegin + 50)
imgUrl = replace(LCase(imgUrl),"/s/", "/")
imgUrl = "<a href=\""&imgUrl&"\" >"
result=result&imgUrl
int imgEnd = Instr(LCase(temp),"/>") + 2
String img = Mid(temp,0, imgEnd)
result=result & img
result=result & "</a>"
content = Mid(temp,imgEnd, len(temp))
begin = Instr(LCase(content),"<img")
if begin = -1 then result=result&content
wend
updateContent=result
end function
%>
版主麻烦帮我看下 我转化的代码 那边还有问题使用的时候提示类型错误<%
function updateContent(content)
dim result
dim temp:temp = ""
int begin = Instr(LCase(content),"<img")
while begin <> -1
result=result & Mid(content,0, begin)
temp = Mid(content,begin)
int imgSrcBegin = Instr(LCase(temp),"src=") + 5
dim imgUrl:imgUrl = Mid(temp,imgSrcBegin, imgSrcBegin + 50)
imgUrl = replace(LCase(imgUrl),"/s/", "/")
imgUrl = "<a href=\""&imgUrl&"\" >"
result=result&imgUrl
int imgEnd = Instr(LCase(temp),"/>") + 2
String img = Mid(temp,0, imgEnd)
result=result & img
result=result & "</a>"
content = Mid(temp,imgEnd, len(temp))
begin = Instr(LCase(content),"<img")
if begin = -1 then result=result&content
wend
updateContent=result
end function
%>
function updateContent(content)
dim result
dim temp:temp = "" <--这里也不能这样定义只要 dim temp就行
int begin = Instr(LCase(content),"<img") <--这里的int是错的 去掉int
while begin <> -1
result=result & Mid(content,0, begin)
temp = Mid(content,begin)
int imgSrcBegin = Instr(LCase(temp),"src=") + 5 <--同样int去掉
dim imgUrl:imgUrl = Mid(temp,imgSrcBegin, imgSrcBegin + 50) 没必要写上dim imgUrl:这个去掉
imgUrl = replace(LCase(imgUrl),"/s/", "/")
imgUrl = "<a href=\""&imgUrl&"\" >"
result=result&imgUrl
int imgEnd = Instr(LCase(temp),"/>") + 2 这里一样 int去掉
String img = Mid(temp,0, imgEnd) 这里String去掉
result=result & img
result=result & "</a>"
content = Mid(temp,imgEnd, len(temp))
begin = Instr(LCase(content),"<img")
if begin = -1 then result=result&content
wend
updateContent=result
end functionASP没有类型定义的只能Dim 变量int String这些在ASP里面都没有的
版主麻烦帮我看下 我转化的代码 那边还有问题使用的时候提示类型错误<%
function updateContent(content)
dim result
dim temp:temp = ""
int begin = Instr(LCase(content),"<img")
while begin <> -1
result=result & Mid(content,0, begin)
temp = Mid(content,begin)
int imgSrcBegin = Instr(LCase(temp),"src=") + 5
dim imgUrl:imgUrl = Mid(temp,imgSrcBegin, imgSrcBegin + 50)
imgUrl = replace(LCase(imgUrl),"/s/", "/")
imgUrl = "<a href=\""&imgUrl&"\" >"
result=result&imgUrl
int imgEnd = Instr(LCase(temp),"/>") + 2
String img = Mid(temp,0, imgEnd)
result=result & img
result=result & "</a>"
content = Mid(temp,imgEnd, len(temp))
begin = Instr(LCase(content),"<img")
if begin = -1 then result=result&content
wend
updateContent=result
end function
%>
function updateContent(content)
dim result
dim temp:temp = "" <--这里也不能这样定义只要 dim temp就行
int begin = Instr(LCase(content),"<img") <--这里的int是错的 去掉int
while begin <> -1
result=result & Mid(content,0, begin)
temp = Mid(content,begin)
int imgSrcBegin = Instr(LCase(temp),"src=") + 5 <--同样int去掉
dim imgUrl:imgUrl = Mid(temp,imgSrcBegin, imgSrcBegin + 50) 没必要写上dim imgUrl:这个去掉
imgUrl = replace(LCase(imgUrl),"/s/", "/")
imgUrl = "<a href=\""&imgUrl&"\" >"
result=result&imgUrl
int imgEnd = Instr(LCase(temp),"/>") + 2 这里一样 int去掉
String img = Mid(temp,0, imgEnd) 这里String去掉
result=result & img
result=result & "</a>"
content = Mid(temp,imgEnd, len(temp))
begin = Instr(LCase(content),"<img")
if begin = -1 then result=result&content
wend
updateContent=result
end functionASP没有类型定义的只能Dim 变量int String这些在ASP里面都没有的
修改为这样了 还是无法运行。function updateContent(content)
dim result
dim temp
begin = Instr(LCase(content),"<img")
while begin <> -1
result=result & Mid(content,0, begin)
temp = Mid(content,begin)
imgSrcBegin = Instr(LCase(temp),"src=") + 5
imgUrl = Mid(temp,imgSrcBegin, imgSrcBegin + 50)
imgUrl = replace(LCase(imgUrl),"/s/", "/")
imgUrl = "<a href=\""&imgUrl&"\" >"
result=result&imgUrl
imgEnd = Instr(LCase(temp),"/>") + 2
img = Mid(temp,0, imgEnd)
result=result & img
result=result & "</a>"
content = Mid(temp,imgEnd, len(temp))
begin = Instr(LCase(content),"<img")
if begin = -1 then result=result&content
wend
updateContent=result
end function