9 – M5 SC 9 Substitutions And Flags V1

Hello, and welcome back. In this lesson, we will learn how to use the re module to modify strings. Regex objects have the sub method that allow us to replace patterns within a string. So, let’s see how this works with a simple example. Here, we have a multi-line string that contains two instances of … Read more

8 – M5 SC 8 Metacharacters Part 3 V1

Hello, and welcome back. In this notebook, we will learn how to make more complicated regular expressions using groups, the question mark, and the asterisk metacharacters. Let’s see how they work. Here, we have a multiline string with the names and the heights of the four highest mountains in the world according to Wikipedia. Our … Read more

7 – M5 SC 7 Metacharacters Part 2 V1

In this notebook, we will see a practical application of regular expressions. In particular, we will use the special sequence backslash d to create regular expressions that will allow us to look for phone numbers. We will also learn about character sets and how they can be used to search for more complicated patterns of … Read more

6 – M5 SC 6 Metacharacters Part 1 V1

In the previous lessons, you learned how to use the backslash meta character to create special sequences. We will now look at the following metacharacters. The dot, the caret, and the dollar sign. Let’s start by looking at the dot. As we saw before, the dot matches any character except newline characters. Let’s see an … Read more

5 – M5 SC 5 Word Boundaries V1

We will now learn about another special sequence that you can create using the backslash, namely backslash b. The special sequence doesn’t really match a particular set of characters, but rather determines word boundaries. A word in this context is defined as a sequence of alphanumeric characters, while a boundary is defined as a whitespace, … Read more

4 – M5 SC 4 Searching For Simple Patte V1

In the previous lessons, we saw how we can match letters, words, and metacharacters. In this notebook, we will see how we can use regular expressions to perform more complex pattern matching using metacharacters. The first metacharacter we’re going to look at is the backslash. We already saw that the backslash can be used to … Read more

3 – M5 SC 3 Finding Metacharacters V1

Now, let’s try to use a regular expression to find this period at the end of our sentence. So, let’s use a period as a regular expression and let’s run this code just as we did before. We can see that something has gone wrong. The finditer method has matched every single character in our … Read more

2 – M5 SC 2 Finding Words V1

In this notebook, you will learn how to find letters and words in a string using regular expressions. Throughout this lessons, we will use the re module from Python’s standard library to work with regular expressions. The re module not only contains functions that allow us to check if a given regular expression matches a … Read more

1 – M5 SC 1 Raw Strings V1

Hello and welcome. The following lessons, we will learn how to create basic regular expressions in Python. As mentioned in the previous lesson, regular expressions or regexes as for short, allows us search for patterns of text in documents. But before we dive in and start creating our regular expressions, let’s take a quick look … Read more