Reading a Text File - Regular Expr?

Results 1 to 2 of 2

Thread: Reading a Text File - Regular Expr?

  1. #1
    Join Date
    Dec 1969

    Default Reading a Text File - Regular Expr?

    Hello all, <BR> I have a file with some text in this format(With spaces in between each word) <BR><BR>"TEXT ACCOUNT 1513 100.30 01-JUN-03 05019000900 IP" <BR><BR>can someone help me how to grab from here the date(01-JUN-03) and the number next to it, any ideas will also be welcome. This is not a Fixed width text file, the date can appear anywhere but always in that format(DD-MON-YY). so far I have the code to open the file, and not sure what to do next. <BR><BR>folderPath = "C:Test" <BR>Set filesystem = Server.CreateObject("Scripting.FileSystemObject") <BR>Set filenamesystem = Server.CreateObject("Scripting.FileSystemObject") <BR><BR>Set prcfolder = filesystem.GetFolder(folderPath) <BR>Set filecollection = prcfolder.Files <BR><BR>For Each file in filecollection <BR> fileName <BR> Set namefile = filenamesystem.OpenTextFile(folderPath & "\" & fileName, 2, True) <BR> &#039; What Next? <BR> <BR>Next <BR><BR>Someone suggested on this group to use a Regualr Expression to get the date, any leads will be appreciated <BR>thanks <BR>das

  2. #2
    Join Date
    Dec 1969

    Default RE: Reading a Text File - Regular Expr?

    &#039; What Next? ...<BR>&#039; namefile is a textstream object<BR>&#039; put file into string variable<BR>str = namefile.ReadAll<BR><BR>Set reg = New RegExp<BR>reg.Pattern = "dd-ww-dd"<BR>reg.IgnoreCase = True<BR>reg.Global = False<BR><BR>Set matches = reg.Execute(str)<BR><BR>If matches.Count &#062; 0 Then<BR> &#039; here&#039;s the month<BR> strMonth = matches[0]<BR>End If<BR><BR><BR>Note:<BR> Use the code below if you gather all the dates from the file. <BR> reg.Global = True<BR> use a For Each Loop on the matches collection<BR><BR>

Posting Permissions

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