How can I replace this code with a RegExReplace expression?
Code: Select all
Text := "
(
Here is a line with a lot of text.
Here is a line with the word often used.
This line has little content.
Another line with often and much.
One further line without matching words.
Example line with often and much.
)"
Word1 := "often"
Word2 := "much"
; Split the text into lines
Lines := StrSplit(Text, "`n")
; Iterate through each line
NewText := ""
Loop, % Lines.MaxIndex()
{
Line := Lines[A_Index]
; Check if the line contains both word1 and word2
if !(InStr(Line, Word1) && InStr(Line, Word2))
{
; Add the line to the new text if both words are not present
NewText .= Line "`n"
}
}
; Output the result
MsgBox % NewText