1
1
mirror of https://github.com/mrabarnett/mrab-regex.git synced 2025-10-05 20:02:39 +02:00

Git issue 546: Partial match not working in some instances with non-greedy capture

This commit is contained in:
Matthew Barnett
2024-11-06 19:48:55 +00:00
parent 64834c729b
commit 930983aa68
5 changed files with 16 additions and 20 deletions

View File

@@ -1,3 +1,7 @@
Version: 2024.11.6
Git issue 546: Partial match not working in some instances with non-greedy capture
Version: 2024.9.14
Reverted to actions/download-artifact@v3 and actions/upload-artifact@v3 in main.yml because GitHub Actions failed when using them.

View File

@@ -16535,9 +16535,6 @@ backtrack:
RE_PARTIAL_RIGHT)
return RE_ERROR_PARTIAL;
if (pos >= limit)
break;
/* Look for the tail string. */
found = string_search(state, test, pos + 1, limit +
length, TRUE, &is_partial);
@@ -16593,9 +16590,6 @@ backtrack:
RE_PARTIAL_RIGHT)
return RE_ERROR_PARTIAL;
if (pos >= limit)
break;
/* Look for the tail string. */
found = string_search_fld(state, test, pos + 1, limit,
&new_pos, &is_partial);
@@ -16651,9 +16645,6 @@ backtrack:
if (pos <= state->text_start && state->partial_side == RE_PARTIAL_LEFT)
return RE_ERROR_PARTIAL;
if (pos <= limit)
break;
/* Look for the tail string. */
found = string_search_fld_rev(state, test, pos - 1,
limit, &new_pos, &is_partial);
@@ -16713,9 +16704,6 @@ backtrack:
RE_PARTIAL_RIGHT)
return RE_ERROR_PARTIAL;
if (pos >= limit)
break;
/* Look for the tail string. */
found = string_search_ign(state, test, pos + 1, limit +
length, TRUE, &is_partial);
@@ -16773,9 +16761,6 @@ backtrack:
if (pos <= state->text_start && state->partial_side == RE_PARTIAL_LEFT)
return RE_ERROR_PARTIAL;
if (pos <= limit)
break;
/* Look for the tail string. */
found = string_search_ign_rev(state, test, pos - 1,
limit - length, TRUE, &is_partial);
@@ -16833,9 +16818,6 @@ backtrack:
if (pos <= state->text_start && state->partial_side == RE_PARTIAL_LEFT)
return RE_ERROR_PARTIAL;
if (pos <= limit)
break;
/* Look for the tail string. */
found = string_search_rev(state, test, pos - 1, limit -
length, TRUE, &is_partial);

View File

@@ -241,7 +241,7 @@ __all__ = ["cache_all", "compile", "DEFAULT_VERSION", "escape", "findall",
"VERSION1", "X", "VERBOSE", "W", "WORD", "error", "Regex", "__version__",
"__doc__", "RegexFlag"]
__version__ = "2.5.147"
__version__ = "2.5.148"
# --------------------------------------------------------------------
# Public interface.

View File

@@ -4346,6 +4346,16 @@ thing
self.assertEqual(regex.match(r"(?i)[^/]*b/xyz", "b/xy", partial=True).span(), (0, 4))
self.assertEqual(regex.match(r"(?i)[^/]*b/xyz", "b/yz", partial=True), None)
# Git issue 546: Partial match not working in some instances with non-greedy capture
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<', partial=True)), True)
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking', partial=True)), True)
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>', partial=True)), True)
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>x', partial=True)), True)
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>xyz abc', partial=True)), True)
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>xyz abc foo', partial=True)), True)
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>xyz abc foo ', partial=True)), True)
self.assertEqual(bool(regex.match(r'<thinking>.*?</thinking>', '<thinking>xyz abc foo bar', partial=True)), True)
def test_fuzzy_ext(self):
self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', 'e')),
True)

View File

@@ -8,7 +8,7 @@ with open('README.rst', encoding='utf-8') as file:
setup(
name='regex',
version='2024.9.11',
version='2024.11.6',
description='Alternative regular expression module, to replace re.',
long_description=long_description,
long_description_content_type='text/x-rst',