regex - C# Regular Expression Nested Paraenthisis Recursive -


need find regular expression.

text = @"{'the quick' | 'the lazy'}{{{'before'} 'fox' } | {{'before'} 'lion'}}" 

result string array should -

[0] = 'the quick' | 'the lazy', [1] = before/1 fox | before/2 lion 

unless 2 or more strings split |, need them side side.

thanks help. after thinking bit, able find simple solution.

string sampletext = "{'what is' | 'when is'}{before/2 }{doing | 'to do'}{ near/3 }{'to ensure our' | 'to ensure that' | 'to make sure our' | 'to make sure our' | 'so our' | 'so our'}{ before/4 }{doesn*t | 'does not' | 'will not' | won*t}";             list<list<string>> list = new list<list<string>>();             match mt = regex.match(sampletext, @"\}([^{]*)\{");             string value = sampletext.replace(mt.value, "},{");             string[] newarray = value.split(",".tochararray());             foreach (string st in newarray)             {                 list.add(new list<string>(st.replace("{", "").replace("}", "").split('|')));             } 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -