- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 C++ VS 2008 去除 RTF 标签以仅在 RTF 文本中进行搜索。
我从 CRichTextEdit
获取到 CString
的 RTF 文本工作正常。下面是我如何尝试删除标签:
std::tr1::cmatch res;
std::string str = note;
const std::tr1::regex rx("({\\)(.+?)(})|(\\)(.+?)(\b)");
std::string replacement = "";
std::string result = std::tr1::regex_replace(str,rx,replacement);
CString strSearchText = result.c_str();
第 3 行在上面的模式中崩溃。一个简单的文本替换模式工作得很好:Ex 将 “fast fox”
中的 “fast”
替换为空字符串。崩溃信息在这里:
First-chance exception at 0x7622fbae in ICView.exe: Microsoft C++ exception: std::tr1::regex_error at memory location 0x0012ee20..
First-chance exception at 0x7622fbae in ICView.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
Unhandled exception at 0x7622fbae in ICView.exe: Microsoft C++ exception: std::tr1::regex_error at memory location 0x0012ee20..
最佳答案
您需要对反斜杠进行转义,因为它们在正则表达式和 C++ 字符串文字中都用作转义字符。这意味着要匹配单个反斜杠,您需要四个反斜杠字符。我认为这应该有效:"({\\\\)(.+?)(})|(\\\\)(.+?)(\\b)"
这应该可以修复异常,但如果它仍然发生,您可以捕获它并使用异常对象的 what() 或 code() 方法来查看问题所在。
编辑:大括号也应该被转义,因为它们是正则表达式中的特殊字符。所以使用:
"(\\{\\\\)(.+?)(\\})|(\\\\)(.+?)(\\b)"
关于c++ - 通过正则表达式崩溃删除 RTF 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1794036/
有谁知道将背景颜色应用于表格单元格的 rtf 标签? 我知道表结构: {\rtf1\ansi\deff0 \trowd \clshdng10000\cellx1000 \clshdng10000
MS Exchange/Outlook 消息使用 MAPI 存储数据。一个常见的 MAPI 属性包含消息正文的富文本版本(0x1009、PR_RTF_COMPRESSED、PidTagRtfCompr
我需要以编程方式生成一个 RTF 文档,其中包含一个垂直合并列的表格,例如 ______________________________ | merged | foo | hello |
我正在尝试增加 柜台 使用以下代码在 BIP 报告的 for-each 循环中将变量增加 1。 然而,柜台 无论有多少循环,变量都不会增加。有人可以指导我如何做到这一点。 我也知道 position(
我需要在 RTF 文件中创建一个表。但是我不熟悉 RΤF。以下是这些 RTF 文件应该替换的文本文件示例: GENERAL JOURNAL
我正在尝试手动生成 RTF 文档,最终会以编程方式完成。我计划改进 pyRTF,使其可以生成“目录”,但我认为它不能。 我无法使用 RTF 控制字(\tc、\tcf 和\tcl.)生成目录。 http
如何在 rtf 中的单元格内制作表格?这是我所知道的最简单的表格: {\rtf\ansi\deff0 \trowd \intbl \cellx1000 Item 1\cell \cellx2000 I
我正在研究 RTF 解析器,但在处理 unicode 时遇到了一些困难。 RTF 规范规定“大于 32767 的 Unicode 值必须表示为负数”( http://www.biblioscape.c
我想更改 RTF 文档的内容,而不是将其另存为 RTF 文档: $defaultRtfFile>> "C:\Users\user\Desktop\Outlokk-Signature\Test.rtf"
我需要一个简单的 HTML2RTF 转换器我尝试运行以下代码...但我收到此代码示例的错误 代码: import java.io.ByteArrayInputStream; import java.i
我想编写一个 python 脚本,将文件编码从 cp949 转换为 utf8。该文件最初以 cp949 编码。我的脚本如下: cpstr = open('terms.rtf').read() utf
有哪些方法可以使用 Java 将 RTF 转换为包含 Windows 或 Unix 文档中表格的 PDF? 我们在这里尝试过的选项是: ITEXT - 但 rtf 文档中的表格在转换为 PDF 后无法
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
似乎不可能为 RTF 项目符号列表找到一个非常简单的工作示例,如下所示: 您好 世界 嵌套(但请以正方形作为项目符号) 也嵌套(也是方形项目符号) 再次定期 我尝试使用 Word 或 TextEdit
我有一个数据框 df 用于 RTF 格式的报告,如下所示: df <- ATRSLBL POPUL CENTRE BAGE BAGEC1 SEX Red PPS 3720
我正在处理由其他人在未知平台上制作的 RTF 文件,并且所有内容都被正确解释,除了一些字符,无论我在 openoffice 中打开它们的任何字符集。这是经过解释的纯文本: "Même taille q
有人知道RTF文件的linter吗? 我正在为文字处理器编写一个简单的 RTF 导出工具。我已经到了我生成的文件现在加载到 OpenOffice 并且似乎可以工作的阶段——除了我刚刚发现如果我从 Op
有人可以帮我将特殊字符转换为可以在 RTF 文件中正确表示的字符吗? 我正在获取 iPad 上存储在字符串中的文本,并使用 NSASCIIStringEncoding 将其输出为 RTF 文件。到目前
我对 RichTextBox.Rtf 属性有点困惑。我正在输入一个混合字体大小的字符串:Test 字体大小为 20,string 字体大小为 10。但是,当我查看 Rtf 时 字符串,我得到以下内容:
我正试图让一个欧元符号显示在 RTF 文档中,但我不太走运。 RTF 文档是一个模板,其中填充了来自 .Net 的数据(通过读取文本流并替换其中的标记)。这些标记之一与欧元符号有关。我的代码按预期工作
我是一名优秀的程序员,十分优秀!