I want a regex for below strings.
string: Some () Text (1)
I want to capture 'Some () Text' and '1'
string: Any () Text
I want to capture 'Any () Text' and '0'
I came up with the following regex to capture 'text' and 'count' but it does not match the 2nd ex above.
@"(?<text>.+)\((?<count>\d+)\)
c#:
string pattern = @"(?<text>.+)\((?<count>\d+)\)";
Match m = Regex.Match(line, pattern);
count = 0;
text = "";
if (m.Success)
{
text = m.Groups["text"].Value.Trim();
int.TryParse(m.Groups["count"].Value, out count);
}