Reputation: 1853
How can perform below shown JavaScript RegEx replace in SQL Server?
var str = "$5,000";
console.log(str.replace(/[$,]/g, ""));
Output:
5000
Upvotes: 1
Views: 348
Reputation: 715
Try this
declare @str money
set @str= cast(cast('$5,000' as money) as int)
Or else if you especially want to use regular expression, you can try the below,
DECLARE @Str varchar(100)
SET @Str = '$5,000'
set @Str = STUFF(@Str, PATINDEX('%[$,]%', @Str),1, '')
select @str
Upvotes: 1