split string by comma code example
Example 1: how to split an input in python by comma
lst = input().split(',')
print (lst)
lst = input().split(' ; ')
print (lst)
Example 2: separate string by comma java
String names = "prappo,prince";
String[] namesList = names.split(",");
Example 3: split string by comma in sql server
CREATE FUNCTION Split
(
@delimited nvarchar(max),
@delimiter nvarchar(100)
) RETURNS @t TABLE
(
id int identity(1,1),
val nvarchar(max)
)
AS
BEGIN
declare @xml xml
set @xml = N'<root><r>' + replace(@delimited,@delimiter,'</r><r>') + '</r></root>'
insert into @t(val)
select
r.value('.','varchar(max)') as item
from @xml.nodes('//root/r') as records(r)
RETURN
END
GO