请问下面的代码怎么用正则表达式提取?
=?GB2312?B?suLK1NK7z8K/tL+0v8nE3MrVz8LAtA==?=
和
=?gb2312?Q?=B7=A2=D3=CA=BC=FE=C0=B2?=
怎么用语句出来编码与内容
我用的是下面这个,但中间的那个B是不确定的,而有可能是其它的字符如Q
=\\?(.+?)\\?B\\?(.+?)\\?=
而且后面
=B7=A2=D3=CA=BC=FE=C0=B2?=
到底是怎么编码的?我用gb2312无法得到呀?
我的代码如下:
System.Text.RegularExpressions.MatchCollection mc;
string strOriginalSubject;
string strSubject1 = string.Empty;
string strSubject = string.Empty;
string strChatset = string.Empty;
int iChatsetStartIndex;
int iSubjectStartIndex;
//@ "=?GB2312?B?suLK1NK7z8K/tL+0v8nE3MrVz8LAtA==?= "
//=?gb2312?Q?=B7=A2=D3=CA=BC=FE=C0=B2?=
strOriginalSubject = @ "=?GB2312?B?suLK1NK7z8K/tL+0v8nE3MrVz8LAtA==?= ";
mc = System.Text.RegularExpressions.Regex.Matches(strOriginalSubject, "=\\?(.+?)\\?B\\?(.+?)\\?= ", System.Text.RegularExpressions.RegexOptions.IgnoreCase);// "=\\?(.+?)\\?B\\?(.+?)\\?= "
foreach (System.Text.RegularExpressions.Match m in mc)
{
strChatset = m.Groups[1].Value; //编码
strSubject1 = m.Groups[2].Value; //标题
if (strChatset != string.Empty)
{
//对主题进行解码
byte[] bSubject = System.Convert.FromBase64String(strSubject1);
strSubject = System.Text.Encoding.GetEncoding(strChatset).GetString(bSubject);
//需要连同编码规则一起替换掉
iChatsetStartIndex = strOriginalSubject.IndexOf( "=? " + strChatset + "? ");