Vbscript:将文本字符串转换为小块并将其放入数组中
我需要大约每 500 个字符(不是特殊字符)将一个长文本字符串分成较小的部分,形成所有句子的数组,然后将它们放在一起,并用特定字符(例如 / /)分隔。内容如下:
“这篇文章是一篇非常非常大的文章。”
所以,我得到:
arrTxt(0) = "This is"
arrTxt(1) = "a very"
arrTxt(2) = "very large text"
...
最后:
response.write arrTxt(0) & "//" & arrTxt(1) & "//" & arrTxt(2)...
由于我对经典 asp 的了解有限,我最接近期望的结果如下:
length = 200
strText = "This text is a very very large."
lines = ((Len (input) / length) - 1)
For i = 0 To (Len (lines) - 1)
txt = Left (input, (i * length)) & "/ /"
response.write txt
Next
但是,这返回一个重复且重叠的文本字符串:“this is // this is a //这是一段文字 //...
对 vbscript 有什么想法吗?谢谢!
I need to break a long text string into smaller pieces approximately once every 500 characters (not a special character), forming an array of all the sentences and then put them together separated by a specific character (eg / /). Something as follows:
"This text is a very very large text."
So, I get:
arrTxt(0) = "This is"
arrTxt(1) = "a very"
arrTxt(2) = "very large text"
...
And finally:
response.write arrTxt(0) & "//" & arrTxt(1) & "//" & arrTxt(2)...
Due to my limited knowledge of classic asp, the closest I came to a desired result was the following:
length = 200
strText = "This text is a very very large."
lines = ((Len (input) / length) - 1)
For i = 0 To (Len (lines) - 1)
txt = Left (input, (i * length)) & "/ /"
response.write txt
Next
However, this returns a repeated and overlapping text string: "this is / / this is a / / this is a text //...
Any idea with vbscript? Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不使用数组,您可以直接构建字符串
如果您确实需要数组,则可以
split(output, DELIMITER)
Without using an array, you can just build the string as you go
If you really need an array, you can then
split(output, DELIMITER)
这是一个尝试:
Here is a try: