There are two questions in your question, so here are a few answers.
Match strings that don't contain a specific string (say .config ):
^(?:(?!\.config).)*$\r?\n?
Match lines that do not end on a specific line:
^.*(?<!\.config)$\r?\n?
and, as a bonus: match lines that do not start with a specific line:
^(?!\.config).*$\r?\n?
(every time, including newlines, if any.
Oh, and answer why your version doesn't work: [^abc] means "any (1) character except a, b or c". Your other solution will also fail on test.hg (because it also ends with the letter g - your regular expression looks at each character separately and not at the whole .config line. So you need lookaround to handle this.
Tim Pietzcker Dec 28 '09 at 10:00 p.m. 2009-12-28 22:00
source share