I am looking for a solution to parse comments out of a large text field that has a lot of RTF special characters in it.
- The comments all begin with\dn0 (plus a space)
- The comment ends with }
- There can be one or more comments
- Would like to add a carriage return / line feed at the end of each comment.
- Will need to do this for each comment record in the data table.
I suspect I need some kind of loop
Here is a mock example:
The desired results are:
Jim
- The comments all begin with\dn0 (plus a space)
- The comment ends with }
- There can be one or more comments
- Would like to add a carriage return / line feed at the end of each comment.
- Will need to do this for each comment record in the data table.
I suspect I need some kind of loop
Here is a mock example:
Code:
declare @thetext1 varchar(5000), @thetext2 varchar(5000)
set @thetext1 = '{\rtf1\ansi\dn0 COMMENT1 IS Here}\fonttbl{\f0\dn0 COMMENT2 IS HERE}froman Tms \colortbl\red0\ dm0 COMMENT3 IS HERE }green0\blue0}}'
set @thetext2 = SUBSTRING(@thetext1,CHARINDEX('dn0 ', @thetext1)+4,200000)
select @thetext2
The desired results are:
Code:
COMMENT1 IS HERE
COMMENT2 IS HERE
COMMENT3 IS HERE
Jim