I have a .txt with some lines with text and blacklist.txt with blacklisted words. I want to get rid of the lines with blacklisted words in them. Simple, right?
Here is what I did:
Code: Select all
; loading the input lines into array
FileRead, InputDump, input.txt
InputArray := StrSplit(InputDump, "`n")
InputLines := InputArray.MaxIndex()
; loading blacklisted words into array
FileRead, BlacklistDump, blacklist.txt
BlacklistArray := StrSplit(BlacklistDump, "`n")
BlacklistLines := BlacklistArray.MaxIndex()
j := 1
Loop
{
CurrentString := InputArray[j]
IsBlacklisted := 0
Loop
{
BlacklistWord := BlacklistArray[A_Index]
IfInString, CurrentString, %BlacklistWord%
{
IsBlacklisted := 1
Break
}
; this is just for debug really
Else
FileAppend, %CurrentString% DOESNT CONTAIN %BlacklistWord%`n, impossibruuuu.txt
}
Until (A_Index = BlacklistLines)
If (IsBlacklisted = 0)
FileAppend, %CurrentString%`n, output.txt
j++
}
Until (j = InputLines)
Code: Select all
Blah Blah Blah
Blah FISH Blah
Poke Poke Mon
Blah Blah Blah
SHIFT FISH blah
Blah FISH SHIFT
Blah FISH Blah
Code: Select all
Fish
Shift
Code: Select all
Blah Blah Blah
Blah FISH Blah
Poke Poke Mon
Blah Blah Blah
Code: Select all
Blah FISH Blah
DOESNT CONTAIN Fish
SHIFT FISH blah
DOESNT CONTAIN Fish
Blah FISH SHIFT
DOESNT CONTAIN Fish