Hi guys,
I'm learning my way through some regex tutorials and have searched but not found what regex flavor Email Parser uses (hopefully knowing will avoid me learning things outside what I am able to do/write for Email Parser).
Thanks.
I'm learning my way through some regex tutorials and have searched but not found what regex flavor Email Parser uses (hopefully knowing will avoid me learning things outside what I am able to do/write for Email Parser).
Thanks.
Thanks logo 11. That's a really good question.
Email Parser uses PCRE (Perl compatible regular expressions). Specifically, the Microsoft .NET framework implementation of PCRE. A link worth checking for those which need more detailed info:
https://msdn.microsoft.com/en-us/library/hs600312(v=vs.100).aspx
In Email Parser, when the text capture method is set to Regular Expression, the program uses the following code. I have simplified it a little bit to better understanding:
Email Parser uses PCRE (Perl compatible regular expressions). Specifically, the Microsoft .NET framework implementation of PCRE. A link worth checking for those which need more detailed info:
https://msdn.microsoft.com/en-us/library/hs600312(v=vs.100).aspx
In Email Parser, when the text capture method is set to Regular Expression, the program uses the following code. I have simplified it a little bit to better understanding:
Regex r = new Regex(this.expression, RegexOptions.IgnoreCase | RegexOptions.Multiline);This means that if a capture group with the same name as the Email Parser field name is defined in the regular expression the value of that capture group is taken. If not the full match is taken as the captured text.
Match m = r.Match(source_text);
if (m.Success && m.Groups[this.field_name] != null && m.Groups[this.field_name].Length > 0)
{
foreach (Capture capture in m.Groups[this.field_name].Captures)
returned.Add(capture.Value);
}
else if (m.Success)
{
foreach (Capture capture in m.Captures)
returned.Add(capture.Value);
}