strings supply pattern and string and ask whether the string matches your pattern after matchparts of the string matched by parts of the pattern are made available to your script that ismatches not only give yes/no answerbut also can pick out substrings as well regular expression pattern strings can be complicated (let' be honest--they can be downright gross to look atbut once you get the hang of themthey can replace larger handcoded string search routines-- single pattern string generally does the work of dozens of lines of manual string scanning code and may run much faster they are concise way to encode the expected structure of text and extract portions of it the re module in pythonregular expressions are not part of the syntax of the python language itselfbut they are supported by the re standard library module that you must import to use the module defines functions for running matches immediatelycompiling pattern strings into pattern objectsmatching these objects against stringsand fetching matched substrings after match it also provides tools for pattern-based splittingreplacingand so on the re module implements rich regular expression pattern syntax that tries to be close to that used to code patterns in the perl language (regular expressions are feature of perl worth emulatingfor instancere supports the notions of named groupscharacter classesand nongreedy matches--regular expression pattern operators that match as few characters as possible (other operators always match the longest possible substringthe re module has also been optimized repeatedlyand in python supports matching for both bytes byte-strings and str unicode strings the net effect is that python' pattern support uses perl-like patternsbut is invoked with different toplevel module interface need to point out up front that regular expressions are complex tools that cannot be covered in depth here if this area sparks your interestthe text mastering regular expressionswritten by jeffrey friedl ( 'reilly)is good next step to take we won' be able to cover pattern construction itself well enough here to turn you into an expert once you learn how to code patternsthoughthe top-level interface for performing matches is straightforward in factthey are so easy to use that we'll jump right into some live examples before getting into more details first examples there are two basic ways to kick off matchesthrough top-level function calls and via methods of precompiled pattern objects the latter precompiled form is quicker if you will be applying the same pattern more than once--to all lines in text filefor instance text and language