I copied the answer from a friend in CSDN last time. The original text is as follows:
======================================
When the number of words in an article is counted and reaches a certain number of words, the output will be truncated, but the page content will be truncated in some inexplicable places, which is not very friendly.
It is easy to find the following symbol near the place to be truncated:
;'"?.!; '".!
If <p> or <br> exists, the page is displayed. It is mainly to study the document format.
<%
If Request. ServerVariables ("Content_Length")> 0 then
Content = Request. Form ("textarea1") PageLength = 1000 'words per page
CLength = Len (content)
PageCount = Int (Clength/PageLength) + 1' calculate the number of pages dim PageArray
Redim PageArray (PageCount) Seperator = Array (chr (13), chr (10 ),". ","! ","? ","; "," "," '")' Separator PageArray (0) = 0
Pos = 0
For j = 0 to ubound (Seperator)
Pos = instr (PageArray (I) + 900, content, Seperator (j) 'pagearray (I) + 900 is near 100 words, adjustable from 1
While Pos> 0 and Pos <(I + 1) * PageLength and Pos> I * PageLength
PageArray (I) = Pos
Pos = instr (Pos + PageLength, content, Seperator (j ))
Wendif PageArray (I)> 0 then
Response. Write "0: I found" & PageArray (I) & "<br>" & j & ": j" & Seperator (j) & "<br>"
J = j + ubound (Seperator) + 1
End if
Nextfor I = 1 to PageCount-1
PageArray (I) = 0
Pos = 0
For j = 0 to ubound (Seperator)
Pos = instr (PageArray (I-1) + 950, content, Seperator (j ))
While Pos> 0 and Pos <(I + 1) * PageLength and Pos> I * PageLength
PageArray (I) = Pos
Pos = instr (Pos + PageLength, content, Seperator (j ))
Wend
If PageArray (I)> 0 then
Response. Write I & ": I found" & PageArray (I) & "<br>" & j & ": j" & Seperator (j) & "<br>"
J = j + ubound (Seperator) + 1
End if
Next
Nextoutput = mid (content, 1, PageArray (0 ))
Output = replace (output, chr (13), "<br> ")
Response. Write "<br> paragraph 1st <br>"
Response. Write outputfor I = 1 to PageCount-2
Output = mid (content, PageArray (I-1) + 1, PageArray (I)-PageArray (I-1 ))
Output = replace (output, chr (13), "<br> ")
Response. Write "<br> section" & I + 1 & "<br>"
Response. Write output
Next 'the output of the last segment has not been written into else
%>
<FORM action = "" method = POST id = form1 name = form1>
<TEXTAREA rows = 70 cols = 120 id = textarea1 name = textarea1>
</TEXTAREA>
<INPUT type = "submit" value = "Submit" id = submit1 name = submit1>
</FORM>
<% End if %>
---------------------------------------------------------------
Defines the length of each page MaxLength
Total text length TotalLength
Scan the hard carriage return at the end of each segment in the article
And calculate the length.
If MaxLength is exceeded, it is split into the first page.
Delete the part before the press Enter.