Hello and welcome back. In this notebook, we will see how to search the parse tree using the class attribute and regular expressions. So, let’s begin by looking at the class attribute. Let’s suppose we wanted to find all the tags that had the attribute class equals “h2style.” Unfortunately, in this case, we can’t simply parse the class attribute to the “find_all” method. The reason is that the CSS attribute class is a reserved word in Python. Therefore, using class as a keyword argument in the “find_all” method will give you a syntax error. To get around this problem, BeautifulSoup has implemented the keyword “class” with an underscore at the end. Let’s see how this works. So, in order to use the “find_all” method to search for all the tags in our sample HTML file that has the attribute class equals “h2style,” we can simply use the class attribute but with the underscore at the end in the “find_all” method. So, if we run this code, we can see that we get the two “h2” tags. Since these are the only two tags in our document, they have the attribute class equals “h2style.” Another nice feature of the “find_all” method is that it can understand regular expressions. That means that we can pass regular expression objects from Python’s RE module to the “find_all” method to search our tree. Let’s see an example. Let’s suppose we wanted to find all the tags in our sample HTML file whose names contain the letter I. To do this, we can use a regular expression, I. So, we can parse a raw string to the compile function of the RE module to get a regular expression object. This regular expression object can then be passed to the “find_all” method as shown here. Just for clarity, in this example, we will only be interested in printing the tag’s name and not the tag’s entire content. For this reason, we will use the dot name attribute of the tag object to only print the tag’s name. So, if we run this code, we can see that we got all the tags whose names contain the letter I.