I need to get some information form a string, and I want to use group name to get information, but I can't do a correct result.
My Code
Regex _Regex = new Regex(@"\AFilePath: (?<FilePath>.+), ContentType: (?<ContentType>.+)[, PrinterName: ]? (?<PrinterName>.+),DownloadFileName: (?<DownloadFileName>.+)\z");
string _String = @"FilePath: C:\Download\TEST.docx, ContentType: WORD, PrinterName: RICOH Aficio MP C4501 PCL 6, DownloadFileName: TEST.docx";
Match _Match = _Regex.Match(_String);
if (_Match.Success == true)
{
string FileNme = _Match.Groups["FilePath"].Value;
string ContentType = _Match.Groups["ContentType"].Value;
string PrinterName = _Match.Groups["PrinterName"].Value;
string DownloadFileName = _Match.Groups["DownloadFileName"].Value;
}
I expect I can get FileNme, CreateTime, PrinterName, DownloadFileName information by the Regex, like this:
FileNme = "C:\Download\TEST.docx"
ContentType = "WORD"
PrinterName = "RICOH Aficio MP C4501 PCL 6"
DownloadFileName = "TEST.docx"
But actually, result with this regex is like this
FileNme = "C:\Download\TEST.docx"
ContentType = "WORD, PrinterName: RICOH Aficio MP C4501 PCL"
PrinterName = "6"
DownloadFileName = "TEST.docx"
