Your question contains two questions, so here are a few answers.
Match lines that don't contain a certain string (say .config
) at all:
^(?:(?!\.config).)*$\r?\n?
Match lines that don't end in a certain string:
^.*(?<!\.config)$\r?\n?
and, as a bonus: Match lines that don't start with a certain string:
^(?!\.config).*$\r?\n?
(each time including newline characters, if present.
Oh, and to answer why your version doesn't work: [^abc]
means "any one (1) character except a, b, or c". Your other solution would also fail on test.hg
(because it also ends in the letter g - your regex looks at each character individually instead of the entire .config
string. That's why you need lookaround to handle this.