aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pyre2/py3/tests/test_namedgroups.txt
diff options
context:
space:
mode:
authorvitalyisaev <vitalyisaev@ydb.tech>2023-11-30 13:26:22 +0300
committervitalyisaev <vitalyisaev@ydb.tech>2023-11-30 15:44:45 +0300
commit0a98fece5a9b54f16afeb3a94b3eb3105e9c3962 (patch)
tree291d72dbd7e9865399f668c84d11ed86fb190bbf /contrib/python/pyre2/py3/tests/test_namedgroups.txt
parentcb2c8d75065e5b3c47094067cb4aa407d4813298 (diff)
downloadydb-0a98fece5a9b54f16afeb3a94b3eb3105e9c3962.tar.gz
YQ Connector:Use docker-compose in integrational tests
Diffstat (limited to 'contrib/python/pyre2/py3/tests/test_namedgroups.txt')
-rw-r--r--contrib/python/pyre2/py3/tests/test_namedgroups.txt56
1 files changed, 56 insertions, 0 deletions
diff --git a/contrib/python/pyre2/py3/tests/test_namedgroups.txt b/contrib/python/pyre2/py3/tests/test_namedgroups.txt
new file mode 100644
index 0000000000..70f561a39f
--- /dev/null
+++ b/contrib/python/pyre2/py3/tests/test_namedgroups.txt
@@ -0,0 +1,56 @@
+Testing some aspects of named groups
+=================================================
+
+ >>> import re2
+ >>> re2.set_fallback_notification(re2.FALLBACK_EXCEPTION)
+
+ >>> m = re2.match(r"(?P<first_name>\w+) (?P<last_name>\w+)", "Malcolm Reynolds")
+ >>> m.start("first_name")
+ 0
+ >>> m.start("last_name")
+ 8
+
+ >>> m.span("last_name")
+ (8, 16)
+ >>> m.regs
+ ((0, 16), (0, 7), (8, 16))
+
+ >>> m = re2.match(u"(?P<first_name>\\w+) (?P<last_name>\\w+)", u"Malcolm Reynolds")
+ >>> m.start(u"first_name")
+ 0
+ >>> m.start(u"last_name")
+ 8
+
+ >>> m.span(u"last_name")
+ (8, 16)
+ >>> m.regs
+ ((0, 16), (0, 7), (8, 16))
+
+Compare patterns with and without unicode
+
+ >>> pattern = re2.compile(br"(?P<first_name>\w+) (?P<last_name>\w+)")
+ >>> print(pattern._dump_pattern().decode('utf8'))
+ (?P<first_name>\w+) (?P<last_name>\w+)
+ >>> pattern = re2.compile(u"(?P<first_name>\\w+) (?P<last_name>\\w+)",
+ ... re2.UNICODE)
+ >>> print(pattern._dump_pattern())
+ (?P<first_name>[_\p{L}\p{Nd}]+) (?P<last_name>[_\p{L}\p{Nd}]+)
+
+Make sure positions are converted properly for unicode
+
+ >>> m = pattern.match(
+ ... u'\u05d9\u05e9\u05e8\u05d0\u05dc \u05e6\u05d3\u05d5\u05e7')
+ >>> m.start(u"first_name")
+ 0
+ >>> m.start(u"last_name")
+ 6
+ >>> m.end(u"last_name")
+ 10
+ >>> m.regs
+ ((0, 10), (0, 5), (6, 10))
+ >>> m.span(2)
+ (6, 10)
+ >>> m.span(u"last_name")
+ (6, 10)
+
+ >>> re2.set_fallback_notification(re2.FALLBACK_QUIETLY)