int start=user.IndexOf('(');
if (start != -1) {
end = user.IndexOf(')', start);
return user.Substring(start+1,end-start-1);
} else
return user;
: IndexOf , Substring, -, , ( , ...)
However, the Daniel L method (using String.Split) can be simpler (but it doesn't work very well with invalid strings and should build a string array).
In general, I suggest that you overcome your aversion to regular expressions, since this situation is exactly what they are intended for :-) ...
source
share