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
Post a Comment