diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2023-12-02 01:45:21 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2023-12-02 02:42:50 +0300 |
commit | 9c43d58f75cf086b744cf4fe2ae180e8f37e4a0c (patch) | |
tree | 9f88a486917d371d099cd712efd91b4c122d209d /contrib/python/pyre2/py2/tests/test_sub.txt | |
parent | 32fb6dda1feb24f9ab69ece5df0cb9ec238ca5e6 (diff) | |
download | ydb-9c43d58f75cf086b744cf4fe2ae180e8f37e4a0c.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/pyre2/py2/tests/test_sub.txt')
-rw-r--r-- | contrib/python/pyre2/py2/tests/test_sub.txt | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/contrib/python/pyre2/py2/tests/test_sub.txt b/contrib/python/pyre2/py2/tests/test_sub.txt new file mode 100644 index 0000000000..b41dd30d28 --- /dev/null +++ b/contrib/python/pyre2/py2/tests/test_sub.txt @@ -0,0 +1,31 @@ +Tests of substitution +===================== + +This first test is just looking to replace things between parentheses +with an empty string. + + + >>> import hashlib + >>> import gzip + >>> import re2 + >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION) + >>> import warnings + >>> warnings.filterwarnings('ignore', category=DeprecationWarning) + + >>> with gzip.open('tests/wikipages.xml.gz', 'rb') as tmp: + ... data = tmp.read() + >>> print(hashlib.md5(re2.sub(b'\(.*?\)', b'', data)).hexdigest()) + b7a469f55ab76cd5887c81dbb0cfe6d3 + + >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY) + +Issue #26 re2.sub replacements with a match of "(.*)" hangs forever + + >>> re2.sub('(.*)', r'\1;replacement', 'original') + 'original;replacement;replacement' + + >>> re2.sub('(.*)', lambda x: x.group() + ';replacement', 'original') + 'original;replacement;replacement' + + >>> re2.subn("b*", lambda x: "X", "xyz", 4) + ('XxXyXzX', 4) |