本文整理匯總了Python中regex.X屬性的典型用法代碼示例。如果您正苦於以下問題:Python regex.X屬性的具體用法?Python regex.X怎麽用?Python regex.X使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類regex
的用法示例。
在下文中一共展示了regex.X屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: regex_search
# 需要導入模塊: import regex [as 別名]
# 或者: from regex import X [as 別名]
def regex_search(
self,
pattern: str,
ignore_case: bool = False,
multiline: bool = False,
dotall: bool = False,
unicode: bool = False,
extended: bool = False,
):
"""Regex search on current data
Args:
pattern (str): Required. The regex pattern to search by
ignore_case (bool, optional): Set case insentive flag. Defaults to False.
multiline (bool, optional): ^/$ match start/end. Defaults to False.
dotall (bool, optional): `.` matches newline. Defaults to False.
unicode (bool, optional): Match unicode characters. Defaults to False.
extended (bool, optional): Ignore whitespace. Defaults to False.
Returns:
Chepy: The Chepy object.
Examples:
>>> c = Chepy("loLolololoL")
>>> c.regex_search("ol", ignore_case=True)
"""
flags = 0
if ignore_case:
flags += re.IGNORECASE
if multiline:
flags += re.MULTILINE
if dotall:
flags += re.DOTALL
if unicode:
flags += re.UNICODE
if extended:
flags += re.X
self.state = re.findall(pattern, self._convert_to_str(), flags=flags)
return self