From 8f24223ca506c007fbbbced0da8ba7f44acdd538 Mon Sep 17 00:00:00 2001 From: Tomer Harpaz Date: Mon, 6 Dec 2021 11:53:49 +0200 Subject: [PATCH] added ` as a path delimit character for quickcopy and updated regexes --- _regex_builds.py | 4 ++-- copytk.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/_regex_builds.py b/_regex_builds.py index 18537c0..9720d46 100644 --- a/_regex_builds.py +++ b/_regex_builds.py @@ -11,8 +11,8 @@ def make_path_regexes(): # paths with at least 3 elements, and never in the first or last element. There cannot # be more than one consecutive space, and it cannot be at the beginning or end of the # element. - edge_delimiters = r'[][\s:=,#$"{}<>()' + "'" + ']' - edge_delimiters_w_slash = r'[][\s:=,#$"{}<>()/' + "'" + ']' + edge_delimiters = r'[][\s:=,#$"{}<>()`' + "'" + ']' + edge_delimiters_w_slash = r'[][\s:=,#$"{}<>()`/' + "'" + ']' leader = r'(?:^|' + edge_delimiters + ')' leader_w_slash = r'(?:^|' + edge_delimiters_w_slash + ')' follower = r'(?:$|' + edge_delimiters + ')' diff --git a/copytk.py b/copytk.py index 8d7d99c..02d24dd 100644 --- a/copytk.py +++ b/copytk.py @@ -39,11 +39,11 @@ def find_command_path(c): # matches common types of urls and things that look like urls 'urls': r'(?:^|[][\s:=,#"{}()'+"'"+r'])([a-zA-Z][a-zA-Z0-9]{1,5}://(?:[a-zA-Z0-9_]+(?::[a-zA-Z0-9_-]+)?@)?(?:(?:[a-zA-Z0-9][\w-]*\.)*[a-zA-Z][\w-]*|(?:[0-2]?[0-9]{1,2}\.){3}[0-2]?[0-9]{1,2})(?::[0-9]{1,5})?(?:/(?:[\w.~%/&-]+|(?:[\w.~%/&-]*\([\w.~%/&-]*\)[\w.~%/&-]*)+)?/?)?(?:\?(?:(?:[\w.~%/&-]+|(?:[\w.~%/&-]*\([\w.~%/&-]*\)[\w.~%/&-]*)+)+(?:=(?:[\w.~%/&-]+|(?:[\w.~%/&-]*\([\w.~%/&-]*\)[\w.~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