gpt4 book ai didi

.net - 清理 RTF 文本

转载 作者:行者123 更新时间:2023-12-04 03:31:23 26 4
gpt4 key购买 nike

我想获取一些 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 语言示例都可以。

最佳答案

我会使用一个隐藏的 RichTextBox,设置 Rtf 成员,然后检索 Text 成员以一种支持良好的方式清理 RTF。然后我会在之后使用手动注入(inject)所需的格式。

关于.net - 清理 RTF 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20450/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com