0

Unfortunately this solution cannot include any functions and is reliant on PCRE.

I am trying to parse the body of an email which contains 2 keywords failed and successful. If both keywords are present anywhere in the email than no match should occur, however if the keyword failed is present without the keyword successful than a match would be made. Is this possible?

An example of the email body that contains both keywords to be parsed is below.

None 
Monitoring stopped (host machine credentials) | 3213450 

Raised on: clusterxyz.geolocation.domain.com 
Time raised: 22 Jun 2020 11:57 AM (UTC-04) 
Time ended: 30 Jun 2020 12:15 PM (UTC-04) 

Details

Machine authentication failed at: 22 Jun 2020 11:57:34 AM 
Machine authentication successful at: 30 Jun 2020 12:15:25 PM

While it may look like I'm just looking for an answer I'd like to share that I've been at this for many hours using the regextester and regexr websites as well as purchasing the RegexBuddy+RegexMagic but still cannot figure out a proper solution and I'm quite exhausted. I am hoping someone can provide me an answer to this question which I can learn from. Thank you

Rob
  • 47
  • 6
  • 1
    `(?s)^(?!.*successful).*failed` or `(?s)^(?!.*\bsuccessful\b).*\bfailed\b` – Wiktor Stribiżew Jun 30 '20 at 17:55
  • 1
    Note that that the regex will fail if `"successful"` is present. You may therefore use the regular expression `^(?!.*\bsuccessful\b).*\bfailed\b`. [ref](https://regex101.com/r/meuC7r/1/) – Cary Swoveland Jun 30 '20 at 18:27

0 Answers0