I take a string of the form xxxx: xxxxx@xxx.xx.xxx.xx: xxx from the StreamReader file. I need to parse the line into 4 parts (before ":", before "@", after "@", and after the second ":" ) and assign values to 4 variables. The question is, what will the regular expression look like for this task?
1 answer
Did like this
public static void ParsingProxy() { var xx = new StreamReader("proxy.txt"); string input = xx.ReadLine(); string pattern = @"(.*):(.*)@(.*):(.*)"; Regex regex = new Regex(pattern); Match match = regex.Match(input); proxyLogin = match.Groups[1].Value; proxyPass = match.Groups[2].Value; proxy = match.Groups[3].Value; port = match.Groups[4].Value; //xx.Close(); } |
строка.Split(":@".ToCharArray());array elements somehow assign to 4 variables. If it’s very boring, the regular season will look like this[:@]:) - nick_n_a