MidTexts
Returns a table of strings extracted from another string based on adjoining strings
- Free Function
- SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017
SELECT *
FROM SQLHTTP.net.MidTexts ( @Text, @Start, @End )
Name | Type | Description |
---|---|---|
@Text | nvarchar(MAX) | String expression to extract from |
@Start | nvarchar(MAX) | String preceding the substring to be retrieved |
@End | nvarchar(MAX) | String proceeding the substring to be retrieved |
Column name | Data type | Description |
---|---|---|
RowID | int | Item Index |
Text | nvarchar(MAX) | Substring retrieved |
StartPosition | int | Start Position |
Retrieving text surrounded by double brackets:
1 2 3 4 5 6 7 8 9 10 11 12 |
DECLARE @Text nvarchar(MAX) DECLARE @Start nvarchar(MAX) DECLARE @End nvarchar(MAX) SET @Text = '[[some]] of these [[words]] are in [[double brackets]]' SET @Start = '[[' SET @End = ']]' SELECT * FROM SQLHTTP.net.MidTexts(@Text, @Start, @End) |
1 2 3 4 5 6 7 |
RowID Text StartPosition ----------- ------------------- -------------- 1 some 3 2 words 21 3 double brackets 38 |