[英]Regular expression how to get filepath
I have a config file like: 我有一个类似的配置文件:
#time(Second or HH:ss:mm) exepath
5 c:\windows\notepad
18:38:00 c:\windows\notepad.exe
18:38:00 "c:\path\path path2\program.exe" command
I want to get time ,filepath and command by regex. 我想通过正则表达式获取时间,文件路径和命令。 I tried:
我试过了:
string line = "18:38:00 c:\windows\notepad.exe.....";//from config file
string reg = @"(\S*)("")?(.*)("")?";
Regex regex = new Regex(reg, RegexOptions.IgnoreCase);
Match m = regex.Match(str);
if(m.Success)
{
Console.Write(" {0} ", m.Groups[1]);
Console.Write(" {0} ", m.Groups[2]);
Console.Write("/n");
}
but that is not work 但这是行不通的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.