http://www.regular-expressions.info/named.html have ever actually read about .net regex ?
The following worked for me:
VS.NET immediate window output:
m[0].Groups["Reference"].Captures[0]
{0ABC123456}
[System.Text.RegularExpressions.Group]: {0ABC123456}
Index: 6
Length: 10
Value: "0ABC123456"
m[1].Groups["Reference"].Captures[0]
{ABC123456}
[System.Text.RegularExpressions.Group]: {ABC123456}
Index: 23
Length: 9
Value: "ABC123456"
The following worked for me:
Code:
Regex r = new Regex(@"^.*\s(?<Reference>0[a-zA-Z]{3}\d{6})|(?<Reference>[a-zA-Z]{3}\d{3,7})", RegexOptions.Multiline);
MatchCollection m = r.Matches("sdssd 0ABC123456" + Environment.NewLine + "asds ABC123456");
m[0].Groups["Reference"].Captures[0]
{0ABC123456}
[System.Text.RegularExpressions.Group]: {0ABC123456}
Index: 6
Length: 10
Value: "0ABC123456"
m[1].Groups["Reference"].Captures[0]
{ABC123456}
[System.Text.RegularExpressions.Group]: {ABC123456}
Index: 23
Length: 9
Value: "ABC123456"

Why do you always have to post something contrary? Is it living in Swindon? Not happpy at your work? Try and ease up a bit mate, you'll grow old and bitter. 
Comment