Regex Expression to remove RTF tags
-
Sunday, March 03, 2013 5:02 PM
I have a file that I get from pulling out values from a Microsoft Lync 2013 conversation that has RTF formatting tags. An example file would be like:
Here is my file:
{\rtf1\fbidis\ansi\ansicpg1254\deff0\nouicompat\deflang1055{\fonttbl{\f0\fnil\fcharset162 Segoe UI;}{\f1\fnil\fcharset238 Segoe UI;}{\f2\fnil Segoe UI;}} {\colortbl ;\red0\green0\blue0;} {\*\generator Riched20 15.0.4420}{\*\mmathPr\mwrapIndent1440 }\viewkind4\uc1 \pard\cf1\embo\f0\fs20 emaillerini\embo0 \embo al \embo0 \f2\par {\*\lyncflags rtf=1}}
I want to remove RTF tags and and just pull out the text of the conversation. So the result of my function should be:
emaillerini al
BTW, I been using Microsoft SQL Server Report Builder for that. I have a expression like below and but it's not working.
=SWITCH(Fields!ContentType.Value = "text/rtf",Code.ConvertRtfToTextRegex(Fields!Body.Value), Fields!ContentType.Value = "text/plain",Fields!Body.Value, Fields!ContentType.Value = "text/html",System.Text.RegularExpressions.Regex.Replace(Fields!Body.Value, "\<[^\>]+\>", ""), Fields!ContentType.Value <> "", Fields!Body.Value )
Thanks,
All Replies
-
Monday, March 04, 2013 12:37 AMI recommend you to use the stored procedure or .net code to process the data and get the desire result and then use these results in ssrs.
-
Monday, March 04, 2013 8:24 AM
I recommend you to use the stored procedure or .net code to process the data and get the desire result and then use these results in ssrs.
First of all ,thanks for your response. Like you said , how can I do the stored procedure to get desired data? I don't know because of I'm newbie. Please clarify.
Thanks & Regards,
-
Monday, March 04, 2013 2:47 PM
Hi,
See this;
http://vmdp.blogspot.com/2011/02/converting-rtf-to-txt-in-ssrs-removing.html
Please mark as answered or vote helpful if this post help resolved your issue. Thanks!
k r o o t z- Proposed As Answer by Mike YinMicrosoft Contingent Staff, Moderator Tuesday, March 05, 2013 6:26 AM
- Marked As Answer by Mike YinMicrosoft Contingent Staff, Moderator Thursday, March 14, 2013 2:20 AM
-
Tuesday, March 05, 2013 6:38 AMModerator
Hi Systemselo,
Just adding to Krootz’s answer. Based on my test, the first method in the link provided by Krootz doesn’t work as expected for your examples. However, the second method works perfectly. So, you can use the second method to convert RTF to txt.
Reference:
Parsing RTF Strings into a ReportRegards,
Mike Yin
TechNet Community Support- Marked As Answer by Mike YinMicrosoft Contingent Staff, Moderator Thursday, March 14, 2013 2:20 AM


