string subject = null;
string toFind = "["+emailFound+"]([.20])";
Match match = Regex.Match(messageText, toFind, RegexOptions.IgnoreCase);
if (match.Success)
{
subject = match.Value;
}
MessageBox.Show(subject);
这是我到目前为止的代码,我是regex的新手,并不太确定它是如何工作的。如何获得“emailFound”之后的前20个字符
由于
答案 0 :(得分:1)
你可以试试这个:
string toFind = Regex.Escape(emailFound)+"(?s)(.{20})";
(?s)
允许点匹配换行符(您可以将其删除并在RegexOptions.SingleLine
方法中添加Match
。)
.{20}
二十个字符
答案 1 :(得分:1)