def _strip(self, tokens, criteria, prop, rev=False):
        """Strip off contiguous tokens from the start or end of the list that meet the criteria."""
        num = len(tokens)
        res = []
        for i, token in enumerate(reversed(tokens) if rev else tokens):
            if criteria(token) and num > i + 1:
                res.insert(0, tokens.pop()) if rev else res.append(tokens.pop(0))
            else:
                break
        if res:
            self[prop] = self._clean(' '.join(res))
        return tokens
def _strip ( self , tokens , criteria , prop , rev = False ) : num = len ( tokens ) res = [ ] for i , token in enumerate ( reversed ( tokens ) if rev else tokens ) : if criteria ( token ) and num > i + 1 : res . insert ( 0 , tokens . pop ( ) ) if rev else res . append ( tokens . pop ( 0 ) ) else : break if res : self [ prop ] = self . _clean ( ' ' . join ( res ) ) return tokens
Strip off contiguous tokens from the start or end of the list that meet the criteria.