def findReplaceFlags(self, tokens):
"""Map letters in |tokens| to re flags."""
flags = re.MULTILINE
if 'i' in tokens:
flags |= re.IGNORECASE
if 'l' in tokens:
# Affects \w, \W, \b, \B.
flags |= re.LOCALE
if 'm' in tokens:
# Affects ^, $.
flags |= re.MULTILINE
if 's' in tokens:
# Affects ..
flags |= re.DOTALL
if 'x' in tokens:
# Affects whitespace and # comments.
flags |= re.VERBOSE
if 'u' in tokens:
# Affects \w, \W, \b, \B.
flags |= re.UNICODE
if 0:
tokens = re.sub('[ilmsxu]', '', tokens)
if len(tokens):
self.setMessage('unknown regex flags '+tokens)
return flags
评论列表
文章目录