I have a legacy code written in VBScript that uses regular expressions I need to rewrite this code in c#. Unfortunately I can't map VBScript RegEx class with "Submatches" collection to respective C# code.
This is VBScript: RegExp=CreateObject("VBScript.RegExp"); RegExp.Pattern = ' some pattern RegExp.IgnoreCase=True; RegExp.Global=True; RegExp.Multiline=True;
Matches=RegExp.Execute(someText);
For Each Match In Matches Do
If Match.SubMatches(4) <> Nothing Then
' some code goes next
Problem is: I can't figure out what is the equivalent C# Regex methods for "Submatches" of VBScript.
My C#:
var Regex = new Regex(@"(\{\n?)|(""(""""|[^""]*)*"")|([^\},\{]+)|(,\n?)|(\}\n?)", RegexOptions.IgnoreCase | RegexOptions.Multiline);
var Matches = Regex.G(textBox1.Text);
var Tree = new SimpleTree<string>();
foreach (var Match in Matches)
{
}
the "Match" object in the "foreach" loop is an "object" and has no any "Submatch" members. How to implement Submatches in C#?