Is there reason following should not work in via .Net but works in RegexBuddy?
String:
formatter:'number',formatoptions:{decimalSeparator:'.',decimalPlaces:2,defaulValue:0}
Expression pattern:
[a-zA-Z]+:({)??([a-zA-Z]+[:](')??[a-zA-Z0-9.,]+(?(3)'|,?),?)+(?(1)}|.)
Produces matches within regex buddy but fail within .net.
private static List<string> GetObjectProps(this string str, out string strWithOutObjectProps)
{
var lst = new List<String>();
var temp = str;
Regex RegexObj = new Regex("[a-zA-Z]+:({)??([a-zA-Z]+[:](')??[a-zA-Z0-9.,]+(?(3)'|,?),?)+(?(1)}|.)");
Match MatchResults = RegexObj.Match(str);
while(MatchResults.Success) //fails
{
lst.Add(MatchResults.Value);
temp = MatchResults.Index > 0
? temp.Substring(0, MatchResults.Index - 1) +
temp.Substring(MatchResults.Index + MatchResults.Length)
: temp.Substring(MatchResults.Index + MatchResults.Length);
MatchResults = MatchResults.NextMatch();
}
strWithOutObjectProps = temp;
return lst;
}
Solution !
Turns out this conflict was on a/c of older regexbuddy, latest version pointed out the error for .net simulation as well.
Reworked Expression :
new Regex(@"\s?\b[a-zA-Z]+\b:\{
(?:
\b[a-zA-Z]+\b:
(?:[0-9]+|'[.,]?'|'[\w]+'),?
)+
\}",
RegexOptions.IgnorePatternWhitespace);
Allthough this expression is not perfect on a/c of having to make the delimiter optional so as to avoid the trailing delimiter, any ideas so as how to avoid this ?