?
@"\((\d+)\)$"
str = str.Substring(0, str.LastIndexOf('(')) + newValue + ")";
something else
string text = "node (1)"; string pattern = @"\(([^)]*)\)"; if (Regex.IsMatch(text, pattern)) { int newValue = 0; string oldValue= Regex.Match(text, pattern).Groups[1].Value; if (int.TryParse( oldValue, out newValue)) newValue++; text = text.Replace(oldValue, newValue.ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)