MCPcopy Create free account
hub / github.com/davidblewett/rure-python / match

Method match

rure/regex.py:88–106  ·  view source on GitHub ↗
(self, string, pos=0, endpos=None)

Source from the content-addressed store, hash-verified

86
87 @accepts_string
88 def match(self, string, pos=0, endpos=None):
89 if self._match_rure is None or pos != self._match_rure_pos:
90 self._match_rure_pos = pos
91 if pos > 0:
92 pattern = self.pattern
93 else:
94 pattern = br'\A' + self.pattern
95 self._match_rure = Rure(pattern,
96 flags=self.rure_flags,
97 **self.options)
98 haystack = string[:endpos].encode('utf8')
99 if self.submatches:
100 captures = self._match_rure.captures(haystack, pos)
101 if captures:
102 return MatchObject(pos, endpos, self, haystack, captures)
103 else:
104 match = self._match_rure.find(haystack, pos)
105 if match:
106 return MatchObject(pos, endpos, self, haystack, 0)
107
108 @accepts_string
109 def split(self, string, maxsplit=0):

Callers 8

matchFunction · 0.80
test_groupMethod · 0.80
test_group_last_matchMethod · 0.80
test_groupsMethod · 0.80
test_groups_optionalMethod · 0.80
test_groupdictMethod · 0.80
test_matchMethod · 0.80

Calls 4

RureClass · 0.90
MatchObjectClass · 0.85
capturesMethod · 0.45
findMethod · 0.45

Tested by 7

test_groupMethod · 0.64
test_group_last_matchMethod · 0.64
test_groupsMethod · 0.64
test_groups_optionalMethod · 0.64
test_groupdictMethod · 0.64
test_matchMethod · 0.64