110,537
社区成员
发帖
与我相关
我的任务
分享
string rtf = base.Rtf;
string DestStr = "";
while (rtf.Contains(@"{\object\objemb{\*\objclass Paint.Picture}"))
{
DestStr += rtf.Substring(0, rtf.IndexOf(@"{\object\objemb{\*\objclass Paint.Picture}"));
rtf = rtf.Substring(rtf.IndexOf(@"{\object\objemb{\*\objclass Paint.Picture}") + @"{\object\objemb{\*\objclass Paint.Picture}".Length);
string temp = rtf.Substring(rtf.IndexOf(@"{\result{\pict\wmetafile0") + @"{\result{\pict\wmetafile0".Length + 6);
DestStr += "[##img##]";
rtf = rtf.Substring(rtf.IndexOf(@"{\result{\pict\wmetafile0") + @"{\result{\pict\wmetafile0".Length + 6);
}
return DestStr + rtf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
namespace sxLdfang
{
class Program
{
static void Main(string[] args)
{
string html = @"{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fswiss\fcharset0 Arial;}{\f1\fnil\fcharset134 \'cb\'ce\'cc\'e5;}}
\viewkind4\uc1\pard\lang2052\f0\fs18 sdfds\f1{\object\objemb{\*\objclass Paint.Picture}\objw360\objh360{\*\objdata
01050000
.....
00000000
}{\result{\pict\wmetafile0
}}}\par
}";
string pattern = @"(?is)(?<={\\object\\objemb{\\\*\\objclass Paint\.Picture}\\objw\d+\\objh\d+{\\\*\\objdata).*(?=}{\\result{\\pict\\wmetafile0
}}}\\par)";
MatchCollection mc = Regex.Matches(html, pattern);
foreach (Match m in mc)
{
Console.WriteLine(m.Value);
}
Console.ReadKey();
}
}
}
运行结果:
01050000
.....
00000000