其中,string=rp(string)令字符串string里的所有"变成"?

帮忙设计两个ASP函数,例如rp(string),nrp(string)。
令&变成&
令<变成<
令>变成>
令空格变成 
令回车变成<br>
而string=nrp(string)是上面那个的逆运算。
把*.asp文件发我邮箱吧415551921@qq.com
令&变成& a m p ;
令<变成& l t ;
令>变成& g t ;
令空格变成& n b s p
令回车变成<br>

小怪兽爱吃肉
浏览 122回答 3
3回答

幕布斯7119047

<%function rp(string)dim strstr=replace(string,chr(34),"&quot;")str=replace(str,chr(38),"&amp;")str=replace(str,chr(39),"&#39;")str=replace(str,"<","&lt;")str=replace(str,">","&gt;")str=replace(str,chr(32),"&nbsp;")str=replace(str,chr(10),"<br>")str=replace(str,chr(13),"")rp=strend functionfunction nrp(string)dim strstr=replace(string,"&quot;",chr(34))str=replace(str,"&#39;",chr(39))str=replace(str,"&lt;","<")str=replace(str,"&gt;",">")str=replace(str,"&nbsp;",chr(32))str=replace(str,"<br>",chr(13)&chr(10))str=replace(str,"&amp;",chr(38))'注意这一句必须放在最后,否则就像楼上的那样,会出现意想不到的结果?nrp=strend function%>把以上的&符号替换为英文状态下的&

动漫人物

Function rp(s)Dim tt = Replace(s, "&", "&amp;")t = Replace(t, "<", "&lt;")t = Replace(t, ">", "&gt;")t = Replace(t, " ", "&nbsp;")t = Replace(t, vbcrlf, "<br>") '这个是Windows换行符,vbcrlfrp = tEnd FunctionFunction nrp(s)Dim tt = Replace(s, "&amp;", "&")t = Replace(t, "&lt;", "<")t = Replace(t, "&gt;", ">")t = Replace(t, "&nbsp;", " ")t = Replace(t, "<br>", vbcrlf)nrp = tEnd Function

慕婉清6462132

主要就是为了 解决文本域 输入回车后 在页面能直接呈现。
打开App,查看更多内容
随时随地看视频慕课网APP