From 834d34a01c7af78ba0bf034f1422edd25cc28045 Mon Sep 17 00:00:00 2001 From: Per von Zweigbergk Date: Sat, 9 Sep 2023 14:21:59 +0200 Subject: [PATCH] Simplify expand_alphanumeric_pattern The regex search of the pattern is unneccessary. Instead, we rely on the new behaviour that terminates early if there are no patterns. --- netbox/utilities/forms/utils.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/netbox/utilities/forms/utils.py b/netbox/utilities/forms/utils.py index bb333bbcc..31f763bae 100644 --- a/netbox/utilities/forms/utils.py +++ b/netbox/utilities/forms/utils.py @@ -94,11 +94,8 @@ def expand_alphanumeric_pattern(string): return parsed_range = parse_alphanumeric_range(pattern) for i in parsed_range: - if re.search(ALPHANUMERIC_EXPANSION_PATTERN, remnant): - for string in expand_alphanumeric_pattern(remnant): - yield "{}{}{}".format(lead, i, string) - else: - yield "{}{}{}".format(lead, i, remnant) + for string in expand_alphanumeric_pattern(remnant): + yield f"{lead}{i}{string}" def expand_ipaddress_pattern(string, family):