Files and regular expressions.

Results 1 to 2 of 2

Thread: Files and regular expressions.

  1. #1
    Conrad Guest

    Default Files and regular expressions.

    --------------------------------------------------------------------------------<BR>Could someone please tell me(or point me to an online article) that would tell me how to do the following:<BR><BR>1) Open a text file<BR>2) Parse that text file for this expression "DSN=mydsn;UID=foo;PWD=bar"<BR>3) Show the value of step 2 to the user.<BR>4) Allow the user to replace that value.<BR>5) Write out the new text over the old text.<BR><BR>I know it requires the FSO, but I need the actual syntax. There a few ways to do this with the FSO, but all the examples that I have seen mix a match these methods. With no clear cut way of doing it.<BR><BR>Thank you for any help that you may render.<BR><BR>Conrad

  2. #2 Guest

    Default RE: Files and regular expressions.

    Sub OpenTextFileTest<BR> Const ForReading = 1, ForWriting = 2, ForAppending = 3<BR> Dim fs, f, txtAll<BR> Set fs = CreateObject("Scripting.FileSystemObject")<BR> Set f = fs.OpenTextFile("c: estfile.txt", ForAppending, false,TristateFalse)<BR>&#039 Then you would use the Replace function to replace the string you looked for with the new one.<BR><BR>txtAll= f.ReadAll<BR> f.Close<BR> Set f = fs.OpenTextFile("c: estfile.txt", ForWriting, true,TristateFalse)<BR> f.write txtAll<BR> f.close<BR> set f=nothing<BR> fs.close<BR> set Fs= nothing<BR>End Sub<BR><BR>Note: The above code is not tested and should be used as a guide only!

Posting Permissions

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