Find John Doe
00:08 and that’s basically everything you need to do for the test string. This will be the part where you will see the visualization in a moment. So next, focus on the regular expression input field at the top.
johndoe in the regular expression input field, you can see that regex101 already highlights
johndoe. That means that the pattern of the regular expression on top is found in the test string. That’s good news for now, but you also want to have the square brackets being found.
01:04 The reason for this is that square brackets are special characters in regular expressions, and that’s where the explanation on the right can help you. regex101 tells you that the square brackets, or your current regular expression pattern, matches a single character present in the list below.
So with square brackets, you basically create a character set that the regular expression will look out for. That will come in handy in a moment, but for now you want literally square brackets, so that’s why you need to add an escape character just before every square bracket. And the escape character is the same one like in Python, and that’s a backslash (
So you’ve got your first regular expression pattern covered. Select and copy the regular expression and save it into a text file because you will need it in a moment. Okay, so with this regular expression covered, let’s take care of the
Become a Member to join the conversation.