I have a string User name (sales) and I want to extract the text between the brackets, how would I do this?
User name (sales)
I suspect sub-string but I can\'t work out
Use this function:
public string GetSubstringByString(string a, string b, string c) { return c.Substring((c.IndexOf(a) + a.Length), (c.IndexOf(b) - c.IndexOf(a) - a.Length)); }
and here is the usage:
GetSubstringByString("(", ")", "User name (sales)")
and the output would be:
sales