1

I am trying to obtain the plain text from a string containing RTF formatting.
For example, I have:

originalText = {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Tahoma;}} \viewkind4\uc1\pard\f0\fs20 the temp is forty degrees\par}

and I want to obtain:

plainText = the temp is forty degrees 

I found the following Regex online: ({\)(.+?)(})|(\)(.+?)()

So I tried this but it just gave me back the original expression:

        pattern = "({\\)(.+?)(})|(\\)(.+?)(\b)";
        plainText = originalText.replace(pattern,"123");
Noor
  • 11
  • 4

0 Answers0