1
我想使用正则表达式从列中删除特定字符。从列中删除特定字符
举个例子,我有这样的:
declare @a nvarchar(50) = '(djfhsd-kjfhksd'
select Replace(@a, Substring(@a, PatIndex('%[^0-9.-]%', @a), 1), '')
但我想只删除括号(),空格和破折号 -
我没有对正则表达式的经验,但我想将它们删除一枪。
我想使用正则表达式从列中删除特定字符。从列中删除特定字符
举个例子,我有这样的:
declare @a nvarchar(50) = '(djfhsd-kjfhksd'
select Replace(@a, Substring(@a, PatIndex('%[^0-9.-]%', @a), 1), '')
但我想只删除括号(),空格和破折号 -
我没有对正则表达式的经验,但我想将它们删除一枪。
declare @a nvarchar(50) = '(djfhsd-kjfhksd'
Select @a =Replace(@a,RemChar,'')
From (Values ('('),
(')'),
('-'),
(' ')
) B (RemChar)
Select @a
返回
djfhsdkjfhksd
对于一些直线前进。否则,你将需要一个UDF或交叉应用
Replace(Replace(Replace(Replace(YourCol,'(',''),')',''),'-',''),' ','')
嗨,感谢你,有没有其他方式使用patindex? – carlosm
哇..什么是逻辑.. –
@carlosm我会再看看 –