Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegEXP match

Status
Not open for further replies.

sfriday

IS-IT--Management
Feb 23, 2002
211
DE
All,

I have a text file that has 100rds of email addresses, I need to write a VBscript file that will find if any matches exist and then delete any duplicates. I copy the original file to a second file so that I can verify howmany times the address appears.

I have so far done

Set rexp = New RegExp
rexp.Global = True
Set objWriter = FSO.OpenTextFile(Agency,8,Create)
Do While not objReader.AtEndOfStream
strline = objReader.ReadLine
rexp.Pattern = strline
Do While not objReader3.AtEndOfStream
strline3 = objReader3.ReadAll
Set mtchs = rexp.Execute(strline3)
If mtchs.count = 1 then
Do While not objReader2.AtEndOfStream
strline2 = objReader2.ReadAll
Set mtchs = rexp.Execute(strline2)
If mtchs.count = 0 then
objWriter.WriteLine(strline)
End If


I am writing out to a file If no matches exist so that I have a clean copy. How do I do a single write if multiple's exist. At present it will not write anything if the match is greater than 1.

Regards
Steve

 
All,

Its OK I fixed it, code shown below

Set rexp = New RegExp
rexp.Global = True
Do While not objReader.AtEndOfStream
strline = objReader.ReadLine
rexp.Pattern = strline
Set objReader2 = FSO.OpenTextFile(Agency)
Do While not objReader2.AtEndOfStream
strline2 = objReader2.ReadAll
Set mtchs = rexp.Execute(strline2)
If mtchs.count = 0 then
Set objWriter = FSO.OpenTextFile(Agency,8,Create)
objWriter.WriteLine(strline)
objWriter.Close
Set objWriter = nothing
End If
Loop
Loop

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top