本文整理汇总了Python中regex.fullmatch方法的典型用法代码示例。如果您正苦于以下问题:Python regex.fullmatch方法的具体用法?Python regex.fullmatch怎么用?Python regex.fullmatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类regex
的用法示例。
在下文中一共展示了regex.fullmatch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import regex [as 别名]
# 或者: from regex import fullmatch [as 别名]
def __init__(
self,
string: Union[str, MutableSequence[str]],
pattern: str,
_match: Match = None,
_type_to_spans: Dict[str, List[List[int]]] = None,
_span: List[int] = None,
_type: str = None,
) -> None:
super().__init__(string, _type_to_spans, _span, _type)
self.pattern = pattern
if _match:
self._match_cache = _match, self.string
else:
self._match_cache = fullmatch(
LIST_PATTERN_FORMAT.replace(
b'{pattern}', pattern.encode(), 1),
self._shadow,
MULTILINE,
), self.string
示例2: is_url
# 需要导入模块: import regex [as 别名]
# 或者: from regex import fullmatch [as 别名]
def is_url(string):
# pattern adapted from CleverCSV
pattern = "((https?|ftp):\/\/(?!\-))?(((([\p{L}\p{N}]*[\-\_]?[\p{L}\p{N}]+)+\.)+([a-z]{2,}|local)(\.[a-z]{2,3})?)|localhost|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\:\d{1,5})?))(\/[\p{L}\p{N}_\/()~?=&%\-\#\.:+]*)?(\.[a-z]+)?"
string = string.strip(" ")
match = regex.fullmatch(pattern, string)
return match is not None
示例3:
# 需要导入模块: import regex [as 别名]
# 或者: from regex import fullmatch [as 别名]
def getmatchingவிதிகள்(நிலைமொழி, வருமொழி):
தொடர்மொழி_விதிகள் =[]
நிலைமொழிவிரி = எழுத்து.உயிர்மெய்விரி(நிலைமொழி)
வருமொழிவிரி = எழுத்து.உயிர்மெய்விரி(வருமொழி)
for விதி in விதிகள்:
if regex.fullmatch(விதி.நிலைமொழி_regex, நிலைமொழிவிரி ) and \
regex.fullmatch(விதி.வருமொழி_regex, வருமொழிவிரி ):
தொடர்மொழி_விதிகள்.append(விதி)
# print(தொடர்மொழி_விதிகள்)
return தொடர்மொழி_விதிகள்
示例4: _match
# 需要导入模块: import regex [as 别名]
# 或者: from regex import fullmatch [as 别名]
def _match(self):
"""Return the match object for the current list."""
cache_match, cache_string = self._match_cache
string = self.string
if cache_string == string:
return cache_match
cache_match = fullmatch(
LIST_PATTERN_FORMAT.replace(
b'{pattern}', self.pattern.encode(), 1),
self._shadow,
MULTILINE)
self._match_cache = cache_match, string
return cache_match
示例5: is_elementary
# 需要导入模块: import regex [as 别名]
# 或者: from regex import fullmatch [as 别名]
def is_elementary(cell):
return not (
regex.fullmatch("[a-zA-Z0-9\.\_\&\-\@\+\%\(\)\ \/]+", cell) is None
)
示例6: __search_node
# 需要导入模块: import regex [as 别名]
# 或者: from regex import fullmatch [as 别名]
def __search_node(self, current_node, fullpath, search_method=False, result=None):
if result is None:
result = []
try:
if regex.match(r"ns=\d*;[isgb]=.*", fullpath, regex.IGNORECASE):
if self.__show_map:
log.debug("Looking for node with config")
node = self.client.get_node(fullpath)
if node is None:
log.warning("NODE NOT FOUND - using configuration %s", fullpath)
else:
log.debug("Found in %s", node)
result.append(node)
else:
fullpath_pattern = regex.compile(fullpath)
for child_node in current_node.get_children():
new_node = self.client.get_node(child_node)
new_node_path = '\\\\.'.join(char.split(":")[1] for char in new_node.get_path(200000, True))
if self.__show_map:
log.debug("SHOW MAP: Current node path: %s", new_node_path)
new_node_class = new_node.get_node_class()
regex_fullmatch = regex.fullmatch(fullpath_pattern, new_node_path.replace('\\\\.', '.')) or \
new_node_path.replace('\\\\', '\\') == fullpath.replace('\\\\', '\\') or \
new_node_path.replace('\\\\', '\\') == fullpath
regex_search = fullpath_pattern.fullmatch(new_node_path.replace('\\\\.', '.'), partial=True) or \
new_node_path.replace('\\\\', '\\') in fullpath.replace('\\\\', '\\')
if regex_fullmatch:
if self.__show_map:
log.debug("SHOW MAP: Current node path: %s - NODE FOUND", new_node_path.replace('\\\\', '\\'))
result.append(new_node)
elif regex_search:
if self.__show_map:
log.debug("SHOW MAP: Current node path: %s - NODE FOUND", new_node_path)
if new_node_class == ua.NodeClass.Object:
if self.__show_map:
log.debug("SHOW MAP: Search in %s", new_node_path)
self.__search_node(new_node, fullpath, result=result)
elif new_node_class == ua.NodeClass.Variable:
log.debug("Found in %s", new_node_path)
result.append(new_node)
elif new_node_class == ua.NodeClass.Method and search_method:
log.debug("Found in %s", new_node_path)
result.append(new_node)
except CancelledError:
log.error("Request during search has been canceled by the OPC-UA server.")
except BrokenPipeError:
log.error("Broken Pipe. Connection lost.")
except OSError:
log.debug("Stop on scanning.")
except Exception as e:
log.exception(e)