Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 不带特定单词的行匹配正则表达式_Javascript_Regex_Regex Negation - Fatal编程技术网

Javascript 不带特定单词的行匹配正则表达式

Javascript 不带特定单词的行匹配正则表达式,javascript,regex,regex-negation,Javascript,Regex,Regex Negation,我试图创建一个正则表达式,它只计算行首不包含特定单词的行。在我的例子中,“迪蒙:” 但这场比赛的其余部分都落在了“迪蒙:”后面,这也是我不想要的 输入: 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-cha

我试图创建一个正则表达式,它只计算行首不包含特定单词的行。在我的例子中,“迪蒙:”

但这场比赛的其余部分都落在了“迪蒙:”后面,这也是我不想要的

输入:

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...
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...
parsing arguments...
path to xml: /home/www/www/seg-chapter/tests/users/1/launches/60/demo.xml
parsing xml file...
匹配:

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...
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...
parsing arguments...
path to xml: /home/www/www/seg-chapter/tests/users/1/launches/60/demo.xml
parsing xml file...
我只想要:

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...
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...
parsing arguments...
path to xml: /home/www/www/seg-chapter/tests/users/1/launches/60/demo.xml
parsing xml file...
你知道如何只匹配行首没有“deamon:”的行吗

str.match( /^(?!deamon:).*/mg )
多行标志
m
表示
^
匹配每行的开头,而不仅仅是字符串的开头。
(?!deamon:)
是一种消极的前瞻,如果一行以
deamon:
开头,它会阻止匹配