I am stuck with regular expressions. The program is a console application written in C #. There are several teams. First I want to check if the arguments are correct. I thought it would be easy with Regex, but could not do this:
var strArgs = "";
foreach (var x in args)
{
strArgs += x + " ";
}
if (!Regex.IsMatch(strArgs, @"(-\?|-help|-c|-continuous|-l|-log|-ip|)* .{1,}"))
{
Console.WriteLine("Command arrangement is wrong. Use \"-?\" or \"-help\" to see help.");
return;
}
Using:
program.exe [-options] [domains]
The problem is that the program accepts all commands. I also need to check the "-" prefix commands in front of the domains. I think the problem is not difficult to solve.
Thank...
source
share