Regex Expression

Status
Not open for further replies.

ssadoglu

Wise, Aged Ars Veteran
119
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:

Code:
 {\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:

Code:
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.

Code:
 =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
     )
 

Maarten

Ars Tribunus Militum
1,840
Subscriptor++
That's not possible, at least not generically. The code:

Code:
{\*\generator Riched20 15.0.4420}

apparently must be removed as well. This requires a full rtf parser, as, as far as I can see, no distinction can be made with a pattern between "Riched20" and "emaillerini".

Perhaps this link will help (Google it). Other pointers are available on wikipedia (look at the end of the page).
 

ssadoglu

Wise, Aged Ars Veteran
119
Maarten":zvsq996f said:
That's not possible, at least not generically. The code:

Code:
{\*\generator Riched20 15.0.4420}

apparently must be removed as well. This requires a full rtf parser, as, as far as I can see, no distinction can be made with a pattern between "Riched20" and "emaillerini".

Perhaps this link will help (Google it). Other pointers are available on wikipedia (look at the end of the page).
Hi there,
As you said,how do I remove "Generator Richard 20"?Can you give me the regex expression which can be used SQL server report builder as mentioned above?
Thanks and best regards,
 
ssadoglu":j0k94nls said:
Dracorat":j0k94nls said:
Why can't you just load it in to an RTF control and then pull the .Text property?

As you mentioned, how can I do? Please clarify.

Thanks and kind regards,

Place a rich text aware control on a form. Load the rich text file into the control, likely using a member LoadFile function. Access the Property, likely named Text, for a plain text version of the data.

This is programming 101 using just about any half-way modern IDE/Language. If your language of choice can't do this in about 5 minutes or less (including looking at help files), you're using the wrong tool.
 
Status
Not open for further replies.