我正在寻找一种从RTF字符串中删除文本的方法,然后我找到了以下的正则表达式:
我想请问这个正则表达式是如何工作的?
I was looking for a way to remove text from and RTF string and I found the following regex:
({\\)(.+?)(})|(\\)(.+?)(\b)
然而,结果字符串含有两个右尖括号 "}"
Before: {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 MS Shell Dlg 2;}{\f1\fnil MS Shell Dlg 2;}} {\colortbl ;\red0\green0\blue0;} {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\tx720\cf1\f0\fs20 can u send me info for the call pls\f1\par }
After: } can u send me info for the call pls }
对于如何改进正则表达式,有什么想法吗?
Edit: 这样更复杂的字符串不起作用:{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 MS Shell Dlg 2;}} {\colortbl ;\red0\green0\blue0;} {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\tx720\cf1\f0\fs20 HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\test\\myapp\\Apps\\\{3423234-283B-43d2-BCE6-A324B84CC70E\}\par }