Regex matching of simple expression
I'm new to regex and can't figure out how to match the following in C# using Regex.Matches
left -> right
I trie开发者_StackOverflow中文版d "(\w) -> (\w)"
but I think I'm way off.
Not way off, you need:
(\w+) -> (\w+)
I would recommend this guide for learning regex.
Match m = Regex.Match("left -> right", @"(\w+) -> (\w+)");
Console.WriteLine(m.Groups[1]); //left
Console.WriteLine(m.Groups[2]); //right
精彩评论