Bob Barrows said:
Joe Reynolds wrote:
say i have a string that is "hello this is my string and i like it
very much" and i want to insert a newline at every 20th character,
how could i go about doing this?
I'm sure someone will post a regex solution for this, but until then:
Here's then:-
s = InsertStringAtInterval(s, vbCrLf, 20))
Function InsertStringAtInterval(rsSource, rsInsert, rlInterval)
Dim rgx
Set rgx = new RegExp
rgx.Pattern = "([\s\S]{" & rlInterval & "})"
rgx.Global = true
InsertStringAtInterval = rgx.Replace(rsSource, "$1" & rsInsert)
End Function
BTW Joe, I still think you should persue a different solution than this.
If you use this in the TD you will actually need:-
s = InsertStringAtInterval(Server.HTMLEncode(s), "<br />", 20))
dim buffer, i, newstring,s
s="hello this is my string and i like it very much"
buffer=20
for i = 1 to len(s) step 20
newstring=newstring & mid(s,i,20) & vbcrlf
next
msgbox newstring
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.