我的电子邮件主题如下:
RE: Blah blah - Blah blah, 1234-56, Blah blah blah
我想知道如何从电子邮件主题中提取1234-56
。
我试过了:
If myemail.Subject Like "****-**" Then
但这只会给我真/假,我想要实际数据1234-56
。
此外,我希望在电子表格中使用find功能来查找数据的位置。
例如,由于电子邮件主题包含1234-56
,我将继续使用我的电子表格并使用查找功能查找1234-56
。
我试过了:
Cells.Find( _
What := myemail.Subject, _
After := ActiveCell, _
LookIn := xlValues, _
LookAt := xlPart, _
SearchOrder := xlByRows, _
SearchDirection := xlNext, _
MatchCase := False, _
SearchFormat := False).Activate
但我不认为这是正确的语法 在此先感谢您的帮助!
答案 0 :(得分:2)
您可以使用正则表达式执行此任务。这是一个示例,显示如何在随机字符串中找到类似private static void FindTagsToRemove(IEnumerable<string> files)
{
var doc = new HtmlDocument();
List<string> scripts = new List<string>();
List<string> errors = new List<string>();
try
{
foreach (var file in files)
{
doc.Load(@file);
var head = doc.DocumentNode.SelectSingleNode("html/head");
var nodes = new List<HtmlNode>();
bool isScript = false;
foreach (var node in head.ChildNodes.ToList())
{
if (node.NodeType == HtmlNodeType.Element && node.Name.Contains("script"))
{
isScript = !isScript;
scripts.Add(node.OuterHtml);
Console.WriteLine(node.OuterHtml);
}
else if (isScript)
{
nodes.Add(node);
node.Remove();
}
}
}
int nr_scripts = scripts.Count();
Console.WriteLine("Number of scripts in collection: {0}", nr_scripts);
}
catch (Exception Ex)
{
Console.WriteLine(Ex.Message);
}
}
(四位,短划线,两位数)的模式。
####-##
要测试和构建模式,您可以轻松使用regex101.com