2
我需要所有可打印特殊字符的圖案。該模式將用於過濾字符串。適用於所有可打印特殊字符的圖案
DECLARE @String NVARCHAR(256) = '[email protected]%$#&' -- input
-- patern for all printable special characters
-- ASCII 33-47, 58-64, 91-96 and 123-126
DECLARE @Pattern NVARCHAR(256)= '%[^ @%$#]%'
WHILE PATINDEX(@Pattern, @String) > 0
SET @String = STUFF(@String, PATINDEX(@Pattern, @String), 1, '')
SELECT @String
--current
- 輸入: '忒@ ST%$#&'
- 輸出: '@%$#'
--desired
- input:'te @ st%$#&'
- output:'@%$#&'
- 輸入: '忒@ ST%$#`〜DAS%^ * 789()€!'
- 輸出: '!@%$#`〜%^ *()'
感謝