From 7ccbb9c6c955bcf98c8c642b73a1983c17305c3b Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Wed, 31 Jul 2024 16:02:53 +0200 Subject: [PATCH] add string split-strip text utility --- scipost_django/common/utils/text.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scipost_django/common/utils/text.py b/scipost_django/common/utils/text.py index 25265f257..fd3106948 100644 --- a/scipost_django/common/utils/text.py +++ b/scipost_django/common/utils/text.py @@ -172,3 +172,10 @@ def remove_extra_spacing(text): Remove extra spacing from text in the form of multiple spaces. """ return " ".join(text.strip().split()) + + +def split_strip(text: str, delimiter=",") -> list[str]: + """ + Split a string by a delimiter and strip each part. + """ + return [part.strip() for part in text.split(delimiter)] -- GitLab