Regular expression for line match without specific word

I'm trying to create regular expression that math only lines that not containing specific word at the beginning of the line. In my case "deamon:".

My regex: (?!d)(?!e)(?!a)(?!m)(?!o)(?!n)(?!:).*n

But this match the rest of line behind "deamon:" too, what I don't want.

Input:

deamon: parsing arguments...
deamon: parsing xml file...
deamon: creating xml file for demo...
deamon: executing demo
parsing arguments...
path to xml: /home/www/www/seg-chapter/tests/users/1/launches/60/demo.xml
parsing xml file...

Match:

parsing arguments...
parsing xml file...
creating xml file for demo...
executing demo
parsing arguments...
path to xml: /home/www/www/seg-chapter/tests/users/1/launches/60/demo.xml
parsing xml file...

I want only:

parsing arguments...
path to xml: /home/www/www/seg-chapter/tests/users/1/launches/60/demo.xml
parsing xml file...

Do you anybody know how to match only lines without "deamon:" at the beginning of the lines?


str.match( /^(?!deamon:).*/mg )

The multiline flag m means ^ matches the start of each line rather than just the start of the string.
(?!deamon:) is a negative look-ahead which prevents a match if a line starts with deamon: .

链接地址: http://www.djcxy.com/p/2158.html

上一篇: 匹配包含特定单词的行的第N个单词

下一篇: 没有特定单词的线匹配的正则表达式