本文整理匯總了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)