Not a regex solution and I'm still a SQL novice so may not be optimal but you should be able to parse with a WHILE loop using
CHARINDEX for the *** then using that as a starting point to
CHARINDEX to the LF Use that as the starting point for a
SUBSTRING with the ending point being a CHARINDEX of the next ***
concatenate the Substring to your output, move past the ending *** and loop to find the next one.
I'll play with it some and see if I can add an example.
EDIT - This probably needs more error checking
declare @inText nvarchar(2000) = 'some text
some text
***[some text]
THIS SHOULD BE EXTRACTED
***[some text]
some text
some text
some text
some text
some text
***[some text]
THIS SHOULD BE EXTRACTED TOO
***[some text]
some text '
declare @delim1 nvarchar(50) = '***'
declare @delim2 char = char(10)
declare @output nvarchar(1000) = ''
declare @position int
declare @positionEnd int
set @position = CHARINDEX(@delim1,@inText)
while (@position != 0 and @position is not null)
BEGIN
set @position = CHARINDEX(@delim2,@inText,@position)
set @positionEnd = CHARINDEX(@delim1,@inText,@position)
set @output = @output + SUBSTRING(@inText,@position,@positionEnd-@position)
set @position = CHARINDEX(@delim1,@inText,@positionEnd+LEN(@delim1))
END
select @output
NVARCHARfieldchar(10)character, but any example working for single-line text is welcome