Got some great help from this post answer a while back here
Now I'm trying take that and capture a couple patterns in my multi-line string but not working. Any hints for me?
Here's a .net fiddle I'm playing with
desired result:
//these can be letters
1: 3333
2: 1111
code:
using System;
using System.Text.RegularExpressions;
public class Program
{
public static void Main()
{
var item = " john smith (ABCDEFG) <js@email.com>\n" +
"target1 = 3333, j\n" +
"target2 1111, ";
String[] patternArr = {"(?:\\s*)",
"(?<target1>target1 = (\\w+)])", // capture the first target
"(?:\\s*)",
"(?<target2>target2 (\\w+))", // captures the second target
};
var pattern = String.Join("", patternArr);
var m = Regex.Match(item, pattern);
if (m.Success)
{
Console.WriteLine("target1: {0}", m.Groups["target1"]);
Console.WriteLine("target2: {0}", m.Groups["target2"]);
}
}
}