in [ ]text "foo bar\ baz \tquxin [ ]re split('\ +'textout[ ]['foo''bar''baz''qux'when you call re split('\ +'text)the regular expression is first compiledthen its split method is called on the passed text you can compile the regex yourself with re compileforming reusable regex objectin [ ]regex re compile('\ +'in [ ]regex split(textout[ ]['foo''bar''baz''qux'ifinsteadyou wanted to get list of all patterns matching the regexyou can use the findall methodin [ ]regex findall(textout[ ][''\ '\ 'to avoid unwanted escaping with in regular expressionuse raw string literals like ' :\xinstead of the equivalent ' :\\xcreating regex object with re compile is highly recommended if you intend to apply the same expression to many stringsdoing so will save cpu cycles match and search are closely related to findall while findall returns all matches in stringsearch returns only the first match more rigidlymatch only matches at the beginning of the string as less trivial examplelet' consider block of text and regular expression capable of identifying most email addressestext """dave dave@google com steve steve@gmail com rob rob@gmail com ryan ryan@yahoo com ""pattern '[ - - %+-]+@[ - - -]+[ - ]{ , }re ignorecase makes the regex case-insensitive regex re compile(patternflags=re ignorecaseusing findall on the text produces list of the -mail addressesin [ ]regex findall(textout[ ]['dave@google com''steve@gmail com''rob@gmail com''ryan@yahoo com'search returns special match object for the first email address in the text for the above regexthe match object can only tell us the start and end position of the pattern in the string data wranglingcleantransformmergereshape www it-ebooks info