If I know which characters I do not want to keep in my string I can easily remove them with REPLACE
:
SELECT REPLACE(
REPLACE(
REPLACE(
'String with characters like #§$ I do not want to keep',
'#', ''
), '§', ''
), '$', ''
) AS repl_string
--- String with characters like I do not want to keep
But, what if I want to remove every character which is not part of a positive list? With a regex
I would so something like s/[^a-zA-Z0-9 :.]//g
(assuming that I would like to allow only letters, numbers, a space
, a dot .
or a colon :
)
I am looking for a solution for Microsoft SQL Server 2016