Improve arrow regex

This commit is contained in:
Daniel Rojas 2020-10-24 15:48:56 +02:00
parent 19d44c32f9
commit b589b68b8a

View File

@ -108,14 +108,16 @@ def open_file_append(filename):
def isarrow(inp): 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 `>`. optionally starting with `<` and/or ending with `>`.
Examples: Examples:
<-, --, ->, <-> <-, --, ->, <->
<==, ==, ==>, <=> <==, ==, ==>, <=>
regex by @shiraneyo
""" """
return bool(re.match(r"^<?[=-]+>?$", inp)) return bool(re.match(r"^\s*(?P<leftHead><?)(?P<body>-+|=+)(?P<rightHead>>?)\s*$", inp))
def aspect_ratio(image_src): def aspect_ratio(image_src):
try: try: