webForumDet fria alternativet
Logga in / Bli medlem

text length

ASP

1 svar · 199 visningar · startad av Organick

Medlem sedan okt. 200120 inlägg
Trådstart#1

I wounder if anyone here knows how I make a recordset that only shows the first 30 words of maybe 300 words.

Medlem sedan dec. 200012 464 inlägg
#2

I do not see how you can do it in your select-statement, but using a regexp in VB-script makes it possible.

set o = new regexp
o.global = true
o.pattern = "(([a-zA-z0-9])*([\ \,\.])*)"
t = rs("yourColumn")
Set Matches = o.Execute(t)
if matches.count > 29 then i = 29 else i = matches.count

response.write mid(t,1,matches.item(i).firstindex+matches.item(i).length)

Probably the pattern may be written in some other manner and you may wish to add some extra characters that delimits words. (I'm rather new to regexp.)

red: Some hatched variable names

251 ms totalt · 4 externa anrop · v20260731065814-full.51f67c91
122 ms — deklarationer (db)
0 ms — hämta statistik (cache)
126 ms — hämta tråd, inlägg och bilagor (db)
122 ms — ändringar (db)