gogetsome
asked on
Trim non alphanumeric characters but leave whitespace alon
Hello I'm using the following function and call to remove non alphanumeric characters from a string.
It does do this but also removes white space.
I need to remove all non alphanumeric characters while leaving white space for our product title field of our products table.
How can I adjust my function to leave the white space?
Select dbo.RemoveNonAlphaCharacte rs('This and that-:(_)')
returns
Thisandthat
It does do this but also removes white space.
I need to remove all non alphanumeric characters while leaving white space for our product title field of our products table.
How can I adjust my function to leave the white space?
Create Function [dbo].[RemoveNonAlphaCharacters](@Temp VarChar(1000))
Returns VarChar(1000)
AS
Begin
Declare @KeepValues as varchar(50) = '%[^a-z0-9]%'
While PatIndex(@KeepValues, @Temp) > 0
Set @Temp = Stuff(@Temp, PatIndex(@KeepValues, @Temp), 1, '')
Return @Temp
End
Select dbo.RemoveNonAlphaCharacte
returns
Thisandthat
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER