diff --git a/pyregexp/engine.py b/pyregexp/engine.py index c9db557..5b0df8b 100644 --- a/pyregexp/engine.py +++ b/pyregexp/engine.py @@ -212,7 +212,7 @@ def match_group(ast: Union[RE, GroupNode, OrNode], string: str) -> Tuple[bool, i ''' nonlocal str_i backtrack_stack = [] - curr_node = ast.children[0] + curr_node = ast.children[0] if len(ast.children) > 0 else None i = 0 # the children i'm iterating, not to confuse with str_i # the passed ast can't be a Leaf diff --git a/setup.py b/setup.py index 55aacc5..1984082 100644 --- a/setup.py +++ b/setup.py @@ -7,14 +7,14 @@ setup( name='pyregexp', packages=['pyregexp'], - version='0.2.1', + version='0.2.2', license='MIT', description='Simple regex library', long_description=long_description, long_description_content_type='text/markdown', author='Lorenzo Felletti', url='https://github.com/lorenzofelletti/pyregex', - download_url='https://github.com/lorenzofelletti/pyregex/archive/v0.2.1.tar.gz', + download_url='https://github.com/lorenzofelletti/pyregex/archive/v0.2.2.tar.gz', keywords=['regex', 'regexp', 'engine'], install_requires=[], classifiers=[ diff --git a/test/test_engine.py b/test/test_engine.py index 3379c33..e36b9f1 100644 --- a/test/test_engine.py +++ b/test/test_engine.py @@ -439,3 +439,24 @@ def test_ignore_case_casefolding(reng: RegexEngine): test_str = "acher" res, _ = reng.match(regex, test_str, ignore_case=2) assert res == False + + +def test_empty_regex(reng: RegexEngine): + regex = r"" + test_str = "aaaa" + res, _ = reng.match(regex, test_str) + assert res == True + + +def test_empty_test_str(reng: RegexEngine): + regex = r"a" + test_str = "" + res, _ = reng.match(regex, test_str) + assert res == False + + +def test_empty_regex_and_test_str(reng: RegexEngine): + regex = r"" + test_str = "" + res, _ = reng.match(regex, test_str) + assert res == True