Skip to content

Commit 4191702

Browse files
committed
change sanitize_string to remove ALL non-alphanumeric chars with underscore
1 parent c777798 commit 4191702

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/borea_python/helpers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
class Helpers:
88
@classmethod
99
def sanitize_string(cls, s: str) -> str:
10-
"""Replace dash, slash, period, comma, pipe, colon, semicolon, and space delimiters with underscore"""
11-
s = re.sub(r"[-/.,|:; ]", "_", s)
12-
# Remove all other special characters (keeping alphanumerics and underscores)
13-
s = re.sub(r"[^\w]", "", s)
10+
"""Replace all non-alphanumeric characters with underscores"""
11+
s = re.sub(r"[\W]", "_", s)
12+
s = re.sub(r"_+", "_", s)
1413
return s
1514

1615
@classmethod

0 commit comments

Comments
 (0)