Append a Quantifier
The moment you add a
2 into it, something’s changed, and it almost seems that you are getting the full timestamp. However, the
0 at the end is not matched. And if you look closely, the visualizer also shows you two different colors.
One is a bit of a lighter blue, and the other one is a bit of a darker blue, and that means the regular expression matches two found tokens from the expression before. So it’s like the
2022 and then the
22 and then the
-0, and then the
8-, and so on.
So it always matches a pair of two. So what you can do now is count the characters that the timestamp contains, and that’s 25. So once you put in
25 here, then you can see that your full timestamp is matched.
01:16 Now the match of the timestamp has the same color, so that means the entity of the timestamp matches your regular expression. Or to be more precise, that your regular expression now matches the timestamp that you have in your test string.
01:31 You can even make one more adjustment to this regular expression, and that’s putting a space on the front of your regular expression because that way, you will also match the space before the timestamp.
02:06 So this will be helpful when you work with the regular expression in the next lesson. Just like before, copy this regular expression and don’t forget the space at the beginning and paste it into a text file.
Become a Member to join the conversation.