Vin*_*ent 10 .net vb.net rtf ms-word
我想取一些RTF输入并清除它以删除除\ ul\b\i之外的所有RTF格式,以便将其粘贴到带有次要格式信息的Word中.
用于粘贴到Word中的命令将类似于:oWord.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(0)(剪贴板中已有一些RTF文本)
{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}}
{\colortbl ;\red255\green255\blue140;}
\viewkind4\uc1\pard\highlight1\lang3084\f0\fs18 The company is a global leader in responsible tourism and was \ul the first major hotel chain in North America\ulnone  to embrace environmental stewardship within its daily operations\highlight0\par
您是否知道如何使用正则表达式或其他东西安全地清理RTF?我使用VB.NET进行处理,但任何.NET语言示例都可以.
我会做类似以下的事情:
Dim unformatedtext As String
someRTFtext = Replace(someRTFtext, "\ul", "[ul]")
someRTFtext = Replace(someRTFtext, "\b", "[b]")
someRTFtext = Replace(someRTFtext, "\i", "[i]")
Dim RTFConvert As RichTextBox = New RichTextBox
RTFConvert.Rtf = someRTFtext
unformatedtext = RTFConvert.Text
unformatedtext = Replace(unformatedtext, "[ul]", "\ul")
unformatedtext = Replace(unformatedtext, "[b]", "\b")
unformatedtext = Replace(unformatedtext, "[i]", "\i")
Clipboard.SetText(unformatedtext)
oWord.ActiveDocument.ActiveWindow.Selection.PasteAndFormat(0)
| 归档时间: | 
 | 
| 查看次数: | 16589 次 | 
| 最近记录: |