I am very new to regular expression , I needed to get specific value from string contained between ' '
Using regular expression was able to get the values but getting an exception when there is a third '
in between ' '
.
Variable rule contains the whole string
IEnumerable<string> possibleValues = Regex
.Matches(rule, @"'(?<val>.*?)'")
.Cast<System.Text.RegularExpressions.Match>()
.Select(match => match.Groups["val"].Value)
.ToArray();
When following string is passed
RULE: 'Street Address'
must be
'Samir Complex, 4th Floor, St Andrew's Road, Bandra (West)' (default value)
Expected values was Street Address and Samir Complex, 4th Floor, St Andrew's Road, Bandra (West)
but getting Street Address and Samir Complex, 4th Floor, St Andrew