如何在正则表达式中获得负面预测以接受更多单词

时间:2015-06-23 10:50:22

标签: regex splunk

我正在尝试为Splunk获取一些数据。

由此:

XYSeriesCollection

我希望将setSeriesStroke()的所有数据都添加到行尾,但如果它包含this my line - Fine (R/S) more date - I like this (not) date - output (yes) -,则不是括号中的数据,因此not中的数据应该是:

yes

我尝试过这样的事情:

group1

但是这给了:

Fine (R/S)
I like this
output

或者这个:

- (.+) (?!(not|yes))

给出:

Fine
I like this
output

1 个答案:

答案 0 :(得分:3)

你可以试试这个,

- ((?:(?!\((?:not|yes)\)).)*)(?=\s|$)

DEMO

- (.*?)(?=\s+\((?:not|yes)\)|$)

这将捕获所有字符,直到达到space(yes)space(no)或该行的结尾。

DEMO