Splits a string around a java-style regular expression.
SPLIT ( 'string', 'regexp' [, index] )
Is an expression of any character type (i.e. nvarchar, varchar, nchar or char).
Is a Java-style regular expression of any character type that is used around ‘string’.
Optional index of result you want to return. If no index value is specified, regexp results are returned as a string separated by single character ‘|’ (pipe).
Splits values from column “s” using different regular expressions and returns results using result index:
select split([s], '[AB]', 0) as a , split([s], '[ABC]', 1) as b , split([s], '[ABC]', 2) as c from ( select 'abaAbbbBccC' as s union all select 'aaaAbbbBcCc' union all select 'oneAtwoBthreeC' ) as dat
a b c —– —– —- aba bbb cc aaa bbb c one two three