between'//find('ham'find substring offset re findall('''//'find all matches/groups ['spam''ham''eggs're findall('''['spam''ham''eggs're findall('/?'''[('spam''ham')('eggs''cheese')re search('/?''todays menu'groups(('spam''ham'especially when using findallthe (?soperator comes in handy to force to match end-of-line characters in multiline textwithout it matches everything except lines ends the following searches look for two adjacent bracketed strings with arbitrary text betweenwith and without skipping line breaksre findall(*'\ \ '[re findall('(? *'\ \ '[('spam''eggs')re findall('(? *?'\ \ '[('spam''ham')stop at \ greedy nongreedy to make larger patterns more mnemonicwe can even associate names with matched substring groups in using the pattern syntax and fetch them by name after matchesthough this is of limited utility for findall the next tests look for strings of "wordcharacters (\wseparated by /--this isn' much more than string splitbut parts are namedand search and findall both scan aheadre search('(? \ *)/(? \ *)'aaa/bbb/ccc]'groups(('aaa''bbb're search('(? \ *)/(? \ *)'aaa/bbb/ccc]'groupdict({'part ''aaa''part ''bbb're search('(? \ *)/(? \ *)'aaa/bbb/ccc]'group( 'bbbre search('(? \ *)/(? \ *)'aaa/bbb/ccc]'group('part ''bbbre findall('(? \ *)/(? \ *)'aaa/bbb ccc/ddd]'[('aaa''bbb')('ccc''ddd')finallyalthough basic string operations such as slicing and splits are sometimes enoughpatterns are much more flexible the following uses [to match any character not following the ^and escapes dash within [alternative set using \so it' not taken to be character set range separator it runs equivalent slicessplitsand matchesalong with more general match that the other two cannot approachline 'aaa bbb cccline[: ]line[ : ]line[ : text and language slice data at fixed offsets