C#, .NET 3.5
This just smells of ugly to me, but I can't think of another way.
Given a string with the format of "Joe Smith (jsmith)" (sans quotes), I'd like to parse out just the 'jsmith' string within the parenthesis. I've come up with this:
private static string DecipherUserName( string user )
{
if( !user.Contains( "(" ) )
return user;
int start = user.IndexOf( "(" );
return user.Substring( start ).Replace( "(", string.Empty ).Replace( ")", string.Empty );
}
Other than my (un)healthy aversion to RegEx, is there a simpler way to parse out the substring?
Edit: To clarify, the string to parse will always be of: "Joe Smith (jsmith)" (sans quotes).