regular expressions so far we have been reading through fileslooking for patterns and extracting various bits of lines that we find interesting we have been using string methods like split and find and using lists and string slicing to extract portions of the lines this task of searching and extracting is so common that python has very powerful library called regular expressions that handles many of these tasks quite elegantly the reason we have not introduced regular expressions earlier in the book is because while they are very powerfulthey are little complicated and their syntax takes some getting used to regular expressions are almost their own little programming language for searching and parsing strings as matter of factentire books have been written on the topic of regular expressions in this we will only cover the basics of regular expressions for more detail on regular expressionsseethe regular expression library re must be imported into your program before you can use it the simplest use of the regular expression library is the search(function the following program demonstrates trivial use of the search function search for lines that contain 'fromimport re hand open('mbox-short txt'for line in handline line rstrip(if re search('from:'line)print(linecodewe open the fileloop through each lineand use the regular expression search(to only print out lines that contain the string "from:this program does not