This is my first experience with C # and part of my limited experience with regular expressions, and I had trouble writing the first match in a specific expression. I believe that the following example will make it more understandable than the words in the description of what I want to do.
Match extractor = (new Regex(@".*\d(?<name>.*)\d.*")).Match("This hopefully will pick up 1Bob9error1 as a name");
Console.WriteLine(extractor.Groups["name"]);
I would like this expression to print “Bob” instead of “error”.
Do I have a suspicion that this has anything to do with this? in front of the appropriate group, but I'm not quite sure what operation? performs in this particular case. An explanation along with some help would be wonderful.
Thank you guys, you have no idea how much this site helps a novice programmer like me.
source
share