asp字符串连接符&、多个字符串相加、字符串拼接类

2023-12-07 0 182

asp中使用&实现字符串的连接

简单字符串连接

response.write \”jb51.net\”&\”悠久资源网\”

多个字符串连接

<%
gettj=\”<a href=\”\”wp-content/uploads/2023/12/zhengze.html\”\” title=\”\”正则表达式30分钟入门教程\”\” target=\”\”_blank\”\”>正则表达式30分钟入门教程</a>\”&vbcrlf
gettj=gettj&\”<a href=\”\”wp-content/uploads/2023/12/181099.htm\”\” title=\”\”揭开正则表达式的神秘面纱(regexlab出品)\”\” target=\”\”_blank\”\”>揭开正则表达式的神秘面纱(regexlab出品)</a>\”&vbcrlf
gettj=gettj&\”<a href=\”\”wp-content/uploads/2023/12/\”\” title=\”\”JavaScript正则表达式在线测试工具\”\” target=\”\”_blank\”\”>JavaScript正则表达式在线测试工具</a>\”&vbcrlf
gettj=gettj&\”<a href=\”\”wp-content/uploads/2023/12/regexsc.htm\”\” title=\”\”正则表达式速查表\”\” target=\”\”_blank\”\”>正则表达式速查表</a>\”&vbcrlf
gettj=gettj&\”<a href=\”\”wp-content/uploads/2023/12/regex.htm\”\” title=\”\”常用正则表达式\”\” target=\”\”_blank\”\”>常用正则表达式</a>\”&vbcrlf
response.write gettj
%>

不如js中直接+=省心

ASP – 字符串拼接类

在ASP中,要拼接字符串的时候,第一个用到的绝对是&,后来在某次项目中,我发现在拼接超长字符串的时候,使用&的效率极低。使用join拼接字符串可使效率提升几百倍。

<%
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字符串连接符&、多个字符串相加、字符串拼接类的详细内容,更多关于asp字符串连接符的资料请关注悠久资源网其它相关文章!

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 ASP编程 asp字符串连接符&、多个字符串相加、字符串拼接类 https://www.u-9.cn/biancheng/asp/126936.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务