Find words in big texts

  • Thread starter Thread starter imre
  • Start date Start date
I

imre

For example: I want to delete everything between <Script ..............>
And </Script......>

My simple method was using a loop that counts to the last character in the
string, using the commands Left() and Mid().
Okay, it works, but my script analyses over 600 pages and rebuilds script,
head and body sections.
So, it uses all my server capacity at onces for about an our !!!

Like:

Sub Page_load(Src As Object, E As Eventargs)

Dim Count, StartPosScript, EndPosScript as integer
Dim str as string = "This is my text and <Script>This is the
script</Scr" & "ipt> That needs to be retrieved and deleted from str"
Dim scri, newstr as string

For count = 1 to len(str)
If left(mid(Str, Count),7) = "<Script" Then StartPosScript =
count
If left(mid(Str, Count),8) = "</Script" Then EndPosScript = count
Next

Scri = left(mid(Str, StartPosScript),(EndPosScript - StartPosScript) +
9)

For count = 1 to len(str)
If count < StartPosScript then newstr = newstr & left(mid(Str,
count),1)
If count > EndPosScript + 8 then newstr = newstr & left(mid(Str,
count),1)
Next

Response.write(server.htmlencode(Str) & "<br>")
Response.write(server.htmlencode(scri) & "<br>")
Response.write(server.htmlencode(newstr) & "<br>")

End sub


Is there a better method to find words, phrases and characters, retrieve
them and/or erase them out of the string ??

Thanks in advance.

Imre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top