Look for a Character Set
00:00
Okay, you looked for the usernames johndoe
and support_tom
or support
anything. You looked for the swear words. The last thing you need to look out for is the timestamp. For this, remove the content that you’re currently having in the regular expression input field, and start with square brackets again, but this time don’t add a backslash in front of it because you want to use the square brackets as regular expression patterns.
00:28
With square brackets and regular expressions, you create character sets. So that means that your regular expression tries to match any character inside your regular expression. Looking at the timestamp, for example, we want to look for a dash (-
).
00:44 Once you put the dash into the regular expression input field, inside of the square brackets, you can see that the visualization of the test string marks all the dashes.
00:54 Next, you also want to look for uppercase Ts.
00:58 At this moment, you also select the Ts of the messages, so that’s something we need to take care of because we don’t want to match them. But for now, let’s focus on the timestamps at hand.
01:09
Look for a colon (:
) and a plus (+
).
01:14
And apart from this, we also look for numbers. So the w
token that we used before doesn’t work for us right now because we don’t have any letters in this. We only look for digits. And for this, you can use the d
token. Just like with the w
before, you need to put a backslash before the d
to not look for the literal character d
, but for the digit regex token.
01:41 And with this, you also match the numbers. So far, so good. However, as mentioned just a moment ago, you also match characters that are not part of the timestamp.
Become a Member to join the conversation.