Skip to content

Latest commit

 

History

History
27 lines (15 loc) · 930 Bytes

split.md

File metadata and controls

27 lines (15 loc) · 930 Bytes

Split

SQL Regex Logo

RegexSplit() is a table-valued function that lets you split a string into pieces using a specified regular expression. RegexSplit() is a SQL CLR table-valued function that exposes the System.Text.RegularExpressions' Split() method.

Let's look at a few examples, inspired by another handy Regular Expressions tutorial

Screenshot

Split SSMS example

Split a String Into Words

Let's split a string into words

declare @regex_pattern varchar(max) = '\s+'

select *
from dbo.RegexSplit('How do I split an arbitrary string into words?', @regex_pattern)

select *
from dbo.RegexSplit('Does this work if   the words are oddly-formed?', @regex_pattern)