code: def build_regex(self, tokens):
          
          patterns = []
          for token in tokens:
              patterns.append(token.pattern_start)
              if token.pattern_end:
                  patterns.append(token.pattern_end)
          return re.compile('|'.join(patterns), re.DOTALL)
docs: Build compound regex from list of tokens