Regex checking if there is no character on a line

Asked

Viewed 49 times

2

I’m having trouble putting together a Regex that checks if there isn’t a character at any point in a row after a pattern.

I have the following log:

3/9/18, 17:47 - Pessoa 1: Oi gente!
3/10/18, 22:59 - Pessoa 2 entrou no grupo.
3/10/18, 09:35 - Pessoa 2: Salve!
O que tá rolando de bom?
3/10/18, 09:36 - Pessoa 1: Quanto tempo!

I need to discard lines in which there is the following pattern: data, hora - aviso., since they are lines referring to the system and not the conversation.

So far, the Regex I’ve been able to assemble is as follows:

\d*\/\d*\/\d*, \d*:\d* - (?!\:)

But the Negative Lookahead (?!\:) only check the character following -, not the rest of the string. What I have to add to Regex to force it to check all the rest of the string?

The demo in regex101 is here.

  • 2

    Why would the messages "Hi people", "Save!" and "How long!" be discarded? They don’t seem to be system warnings. Or you differentiate these messages due to the presence of two points?

1 answer

0


I got the solution, the Regex that checks if there are no two points after this pattern is:

\d+/\d+\/\d+, \d+:\d+ -(?=[^:]+$)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.