regex - get character only string from another string in sql server -
regex - get character only string from another string in sql server -
i looking solution character based string extracted string. need first 4 "characters only" string. restriction here "another" string may contain spaces, special characters, numbers etc , may less 4 characters.
for illustration - should get
"nagp" if source string "nagpur district"
"illf" if source string "ill fated"
"raju" if source string "ra123 *ju23"
"mac" if source string "mac"
any help appreciated.
thanks sharing time , wisdom.
you can utilize reply in question , add together substring method value of desired length how strip non-alphabetic characters string in sql server?
i.e.
create function [dbo].[removenonalphacharacters](@temp varchar(1000)) returns varchar(1000) begin declare @keepvalues varchar(50) set @keepvalues = '%[^a-z]%' while patindex(@keepvalues, @temp) > 0 set @temp = stuff(@temp, patindex(@keepvalues, @temp), 1, '') homecoming @temp end
use like
select substring(dbo.removenonalphacharacters('abc1234def5678ghi90jkl'), 1, 4);
here substring used string of length 4 returned value.
sql-server regex string
Comments
Post a Comment