rename RE constants
This commit is contained in:
parent
878bf34d52
commit
ae9ca16aaa
1 changed files with 5 additions and 5 deletions
|
@ -4,11 +4,11 @@ from random import Random
|
||||||
|
|
||||||
from pydantic import BaseModel, field_validator
|
from pydantic import BaseModel, field_validator
|
||||||
|
|
||||||
_RE_WHITESPACE = re.compile(
|
RE_WHITESPACE = re.compile(
|
||||||
pattern=r"\s+",
|
pattern=r"\s+",
|
||||||
flags=re.UNICODE | re.IGNORECASE,
|
flags=re.UNICODE | re.IGNORECASE,
|
||||||
)
|
)
|
||||||
_RE_SPECIAL_CHARS = re.compile(
|
RE_SPECIAL_CHARS = re.compile(
|
||||||
pattern=r"[^a-zA-Z0-9\s]+",
|
pattern=r"[^a-zA-Z0-9\s]+",
|
||||||
flags=re.UNICODE | re.IGNORECASE,
|
flags=re.UNICODE | re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
@ -67,14 +67,14 @@ class TransformedString(BaseModel):
|
||||||
result = result.strip()
|
result = result.strip()
|
||||||
|
|
||||||
elif self.whitespace is TransformedString.__Whitespace.SPACE:
|
elif self.whitespace is TransformedString.__Whitespace.SPACE:
|
||||||
result = _RE_WHITESPACE.sub(string=result, repl=" ")
|
result = RE_WHITESPACE.sub(string=result, repl=" ")
|
||||||
|
|
||||||
elif self.whitespace is TransformedString.__Whitespace.REMOVE:
|
elif self.whitespace is TransformedString.__Whitespace.REMOVE:
|
||||||
result = _RE_WHITESPACE.sub(string=result, repl="")
|
result = RE_WHITESPACE.sub(string=result, repl="")
|
||||||
|
|
||||||
# Sonderzeichen verarbeiten
|
# Sonderzeichen verarbeiten
|
||||||
if self.special_chars is TransformedString.__SpecialChars.REMOVE:
|
if self.special_chars is TransformedString.__SpecialChars.REMOVE:
|
||||||
result = _RE_SPECIAL_CHARS.sub(string=result, repl="")
|
result = RE_SPECIAL_CHARS.sub(string=result, repl="")
|
||||||
|
|
||||||
# Groß-/Kleinschreibung verarbeiten
|
# Groß-/Kleinschreibung verarbeiten
|
||||||
if self.case is TransformedString.__Case.UPPER:
|
if self.case is TransformedString.__Case.UPPER:
|
||||||
|
|
Loading…
Reference in a new issue