Converting Text within a page

Results 1 to 2 of 2

Thread: Converting Text within a page

  1. #1
    Rick Gammons Guest

    Default Converting Text within a page

    I am looking to search through a given document, find a somewhat predetermined string within the document - for example -<BR>^xxxx^ <BR>where ^ denotes that this is one of the strings I am looking for, yet xxxx can be any combination of letters, numbers, symbols.<BR><BR>First, I need to be able to locate the string, which should be fairly simple by searching for ^, but then I need to take and extract the string inside the ^ ^ - however many characters it might be, and replace it with an expanded version of itself back into the document and then move on to the next instance of ^.<BR><BR>For example - if the string is ^hello^, then I want to be able to replace it with just hello, except make it an active link to a welcome page on my site, for example and then move on to the next instance of ^.<BR><BR>Or another example, if the string is ^dogs^ it replaces it, including the ^ symbols with just dogs that is an active link to a dogs page on my site. If the string is ^Asia^ it writes Asia as an active link to a page on my site about Asia and then move on to the next instance of ^.<BR><BR>I need to cycle through the entire document and continually replace the strings within those ^ symbols with the same string that is inside them, only creating them as active links to different pages.<BR><BR>Any help anyone can give as quickly as possible is much appreciated. Thanks.<BR><BR>

  2. #2
    Rokea Guest

    Default RE: Converting Text within a page

    Depending on what you exactly want to do, i may have a way of solving this, as there obviously exist many many ways to solve your problem.<BR><BR>I supose you have an awfull lot of pages to do this to? else i would put my efforts in a simple find/replace textpad function.. but anyway :)<BR><BR>Here is the part handling the file object:<BR><BR>Dim fs, a<BR>Set fs = CreateObject("Scripting.FileSystemObject")<BR>Set a = fs.OpenTextFile("c: estfile.txt", ForReading, False)<BR>Do While a.AtEndOfLine &#060;&#062; True<BR> Your-Code-Here!<BR>Loop<BR>a.Close<BR><BR>Now, in the your code here part, youll have to check out and test it out since i dont have time to program it all for you.. but here is the idea:<BR><BR>Use the function ReadLine:<BR>dim strtemp<BR>strtemp = a.ReadLine<BR><BR>Then search in your string your "^" first characters, then read on one character by one character (in an other variable) until you reach the second "^", then use the Replace function (search for the word you just put in the other variable and replace it by the link you want to put on your page.<BR><BR>Go this way all along the line you read from the file.<BR><BR>Then use the WriteLine method:<BR>a.WriteLine(strtemp)<BR><BR>and then loop back and do those steps again..<BR><BR>Hope this helps, give me feedback about it..<BR><BR>Rokea

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts