diff options
| author | Jim Mussared <jim.mussared@gmail.com> | 2022-08-18 16:57:45 +1000 |
|---|---|---|
| committer | Jim Mussared <jim.mussared@gmail.com> | 2023-06-08 17:54:24 +1000 |
| commit | 4216bc7d1351feb8199e4ebbff1a9598aa1c5b02 (patch) | |
| tree | 5085738ef65ab377c221f290c7fa90ec2acd4d29 /tests/extmod/re_namedclass.py | |
| parent | 5e50975a6dd9466afafbcd012c00078093fe1f57 (diff) | |
tests: Replace umodule with module everywhere.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'tests/extmod/re_namedclass.py')
| -rw-r--r-- | tests/extmod/re_namedclass.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/extmod/re_namedclass.py b/tests/extmod/re_namedclass.py new file mode 100644 index 000000000..442172f4a --- /dev/null +++ b/tests/extmod/re_namedclass.py @@ -0,0 +1,36 @@ +# test named char classes + +try: + import re +except ImportError: + print("SKIP") + raise SystemExit + + +def print_groups(match): + print("----") + try: + i = 0 + while True: + print(match.group(i)) + i += 1 + except IndexError: + pass + + +m = re.match(r"\w+", "1234hello567 abc") +print_groups(m) + +m = re.match(r"(\w+)\s+(\w+)", "ABC \t1234hello567 abc") +print_groups(m) + +m = re.match(r"(\S+)\s+(\D+)", "ABC \thello abc567 abc") +print_groups(m) + +m = re.match(r"(([0-9]*)([a-z]*)\d*)", "1234hello567") +print_groups(m) + +# named class within a class set +print_groups(re.match("([^\s]+)\s*([^\s]+)", "1 23")) +print_groups(re.match("([\s\d]+)([\W]+)", "1 2-+=")) +print_groups(re.match("([\W]+)([^\W]+)([^\S]+)([^\D]+)", " a_1 23")) |
