table regular expression object methods syntax description rx findall( startendreturns all nonoverlapping matches of the regex in string (or in the start:end slice of sif the regex has captureseach match is returned as tuple of captures rx finditer( startendreturns match object for each nonoverlapping match in string (or in the start:end slice of srx flags the flags that were set when the regex was compiled rx groupindex rx pattern dictionary whose keys are capture group names and whose values are group numbersempty if no names are used returns match object if the regex matches at the start of string (or at the start of the start:end slice of )otherwisereturns none the string from which the regex was compiled rx search(sstartendreturns match object if the regex matches anywhere in string (or in the start:end slice of )otherwisereturns rx match(sstartendnone rx split(smreturns the list of strings that results from splitting string on every occurrence of the regex doing up to splits (or as many as possible if no is givenif the regex has capturesthese are included in the list between the parts they split rx sub(xsmreturns copy of string with every (or up to if givenmatch replaced with --this can be string or functionsee text the same as re sub(except that it returns -tuple of the resultant string and the number of substitutions that were made rx subn(xs mone common task is to take an html text and output just the plain text that it contains naturally we could do this using one of python' parsersbut simple tool can be created using regexes there are three tasks that need to be donedelete any tagsreplace entities with the characters they representand insert blank lines to separate paragraphs here is function (taken from the html text py programthat does the jobdef html text(html_text)def char_from_entity(match)code html entities name codepoint get(match group( ) xfffdreturn chr(code