Regex 2项的正则表达式,但有一项除外

Regex 2项的正则表达式,但有一项除外,regex,regex-negation,Regex,Regex Negation,我正在构建一个正则表达式,该正则表达式需要查找以下行: DateTime.Now or Date.Now 但不能将文字“SystemDateTime”放在同一行上 我是从这个(DateTime\.Now | Date\.Now)开始的,但是现在我被困在哪里放置“SystemDateTime”使用这个。假设您没有使用在点()下接受换行符的/s修饰符(或DOTALL) (?!*SystemDateTime)表示前面没有SystemDateTime。您可以这样使用: (?!.*SystemDate

我正在构建一个正则表达式,该正则表达式需要查找以下行:

DateTime.Now
or 
Date.Now
但不能将文字“
SystemDateTime
”放在同一行上


我是从这个
(DateTime\.Now | Date\.Now)
开始的,但是现在我被困在哪里放置“
SystemDateTime

使用这个。假设您没有使用在点(
)下接受换行符的
/s
修饰符(或
DOTALL

(?!*SystemDateTime)
表示前面没有
SystemDateTime

您可以这样使用:

(?!.*SystemDateTime)\bDate(?:Time)?\.Now\b

说明:

Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!.*SystemDateTime)»
   Match any single character that is not a line break character «.*»
      Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
   Match the characters “SystemDateTime” literally «SystemDateTime»
Match the characters “Date” literally «Date»
Match the regular expression below «(?:Time)?»
   Between zero and one times, as many times as possible, giving back as needed (greedy) «?»
   Match the characters “Time” literally «Time»
Match the character “.” literally «\.»
Match the characters “Now” literally «Now»
/(?!.*SystemDateTime)Date(?:Time)?\.Now/
Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!.*SystemDateTime)»
   Match any single character that is not a line break character «.*»
      Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
   Match the characters “SystemDateTime” literally «SystemDateTime»
Match the characters “Date” literally «Date»
Match the regular expression below «(?:Time)?»
   Between zero and one times, as many times as possible, giving back as needed (greedy) «?»
   Match the characters “Time” literally «Time»
Match the character “.” literally «\.»
Match the characters “Now” literally «Now»