From b589b68b8a02473e591d8b2e53e05ad0c0d57f40 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Sat, 24 Oct 2020 15:48:56 +0200 Subject: [PATCH] Improve arrow regex --- src/wireviz/wv_helper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py index 49ba8fe..270afad 100644 --- a/src/wireviz/wv_helper.py +++ b/src/wireviz/wv_helper.py @@ -108,14 +108,16 @@ def open_file_append(filename): def isarrow(inp): """ - Matches strings of one or multiple `-` or `=` (TODO: but not mixed) + Matches strings of one or multiple `-` or `=` (but not mixed) optionally starting with `<` and/or ending with `>`. Examples: <-, --, ->, <-> <==, ==, ==>, <=> + + regex by @shiraneyo """ - return bool(re.match(r"^?$", inp)) + return bool(re.match(r"^\s*(?P-+|=+)(?P>?)\s*$", inp)) def aspect_ratio(image_src): try: