正则表达式模式需要帮助
原始字符串是这样的:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 MS Shell Dlg 2;}}
\viewkind4\uc1\pard\sb100\sa100\f0\fs24\u30340?\u27494?\u35013?\u20998?\u23376?\u65292?23\u26085?\u22312?\u33778?\u24459?\u23486?\u21335?\u37096?\u30340?\u39532?\u20140?\par
\pard\f1\fs17\par
by: lena (11/26/09)\par
\par
}
将斜杠后面的所有 RTF 标记替换为除 \unumbers
之外的“”空字符串的正则表达式模式是什么? 结果应该如下所示:
\u30340?\u27494?\u35013?\u20998?\u23376?\u65292?23\u26085?\u22312?\u33778?\u24459?\u23486?\u21335?\u37096?\u30340?\u39532?\u20140?
by: lena (11/26/09)
我尝试了 "\\\\\\w+|\\{.*?\\}|\\}"
,它删除了反斜杠和所有大括号后面的所有内容。缺少的部分类似于 \\!(\\\\u)
The raw string is like this:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 MS Shell Dlg 2;}}
\viewkind4\uc1\pard\sb100\sa100\f0\fs24\u30340?\u27494?\u35013?\u20998?\u23376?\u65292?23\u26085?\u22312?\u33778?\u24459?\u23486?\u21335?\u37096?\u30340?\u39532?\u20140?\par
\pard\f1\fs17\par
by: lena (11/26/09)\par
\par
}
What is the regex pattern that would replace all RTF tags following a slash with "" empty string except \unumbers
?
The result should look like:
\u30340?\u27494?\u35013?\u20998?\u23376?\u65292?23\u26085?\u22312?\u33778?\u24459?\u23486?\u21335?\u37096?\u30340?\u39532?\u20140?
by: lena (11/26/09)
I tried "\\\\\\w+|\\{.*?\\}|\\}"
which removes all that follows a backslash and all curly braces. The missing part is something like \\!(\\\\u)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先尝试匹配您要保留的标签并替换它们。
Try matching the tags you want to keep first and replace them.