asp字符串连接符&、多个字符串相加、字符串拼接类
这篇文章主要介绍了asp字符串连接符&、多个字符串相加、字符串拼接类,需要的朋友可以参考下
asp中使用&实现字符串的连接
简单字符串连接
response.write "jb51.net"&"脚本之家"
多个字符串连接
1 2 3 4 5 6 7 8 | <% gettj= "<a href=" "https://www.jb51.net/tools/zhengze.html" " title=" "正则表达式30分钟入门教程" " target=" "_blank" ">正则表达式30分钟入门教程</a>" &vbcrlf gettj=gettj& "<a href=" "https://www.jb51.net/article/181099.htm" " title=" "揭开正则表达式的神秘面纱(regexlab出品)" " target=" "_blank" ">揭开正则表达式的神秘面纱(regexlab出品)</a>" &vbcrlf gettj=gettj& "<a href=" "http://tools.jb51.net/regex/javascript/" " title=" "JavaScript正则表达式在线测试工具" " target=" "_blank" ">JavaScript正则表达式在线测试工具</a>" &vbcrlf gettj=gettj& "<a href=" "https://www.jb51.net/tools/regexsc.htm" " title=" "正则表达式速查表" " target=" "_blank" ">正则表达式速查表</a>" &vbcrlf gettj=gettj& "<a href=" "https://www.jb51.net/tools/regex.htm" " title=" "常用正则表达式" " target=" "_blank" ">常用正则表达式</a>" &vbcrlf response.write gettj %> |
不如js中直接+=省心
ASP - 字符串拼接类
在ASP中,要拼接字符串的时候,第一个用到的绝对是&,后来在某次项目中,我发现在拼接超长字符串的时候,使用&的效率极低。使用join拼接字符串可使效率提升几百倍。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | <% Class appendString Private arrIndex, arrUbound, arrList() Private Sub Class_Initialize() ‘分配10长度 redim arrList(10) ‘当前长度 arrIndex = 0 '每次扩展长度 arrUbound = 10 End Sub Private Sub Class_Terminate() '释放所有数组,再次使用时,需要重新分配 Erase arrList End Sub ‘设置值并动态扩展长度 Public Default Sub Add(value) arrList(arrIndex) = value arrIndex = arrIndex + 1 if arrIndex > arrUbound then arrUbound = arrUbound + 50 redim preserve arrList(arrUbound) end if End Sub '返回字符串 Public Function getString(splitString) redim preserve arrList(arrIndex - 1) getString = join(arrList,splitString) End Function End Class '调用方法 Set StringClass = New appendString StringClass.add( "我" ) StringClass.add( "爱" ) StringClass.add( "编" ) StringClass.add( "程" ) OutputString = StringClass.getString( "" ) '打印结果是:我爱编程 %> |
以上就是asp字符串连接符&、多个字符串相加、字符串拼接类的详细内容