'Find instances of the regular expression in the text.
The text is a list of tokens, and a regexp pattern to match
a single token must be surrounded by angle brackets.  E.g.
>>> from nltk.text import TokenSearcher
>>> print(\'hack\'); from nltk.book import text1, text5, text9
hack...
>>> text5.findall("<.*><.*><bro>")
you rule bro; telling you bro; u twizted bro
>>> text1.findall("<a>(<.*>)<man>")
monied; nervous; dangerous; white; white; white; pious; queer; good;
mature; white; Cape; great; wise; wise; butterless; white; fiendish;
pale; furious; better; certain; complete; dismasted; younger; brave;
brave; brave; brave
>>> text9.findall("<th.*>{3,}")
thread through those; the thought that; that the thing; the thing
that; that that thing; through these than through; them that the;
through the thick; them that they; thought that the
:param regexp: A regular expression
:type regexp: str'

def findall(self, regexp):

    regexp = re.sub(u'\\s', u'', regexp)
    regexp = re.sub(u'<', u'(?:<(?:', regexp)
    regexp = re.sub(u'>', u')>)', regexp)
    regexp = re.sub(u'(?<!\\\\)\\.', u'[^>]', regexp)
    hits = re.findall(regexp, self._raw)
    for h in hits:
        if ((not h.startswith(u'<')) and h.endswith(u'>')):
            raise ValueError(u'Bad    regexp    for    TokenSearcher.findall')
    hits = [h[1:(-1)].split(u'><') for h in hits]
    return hits
