Extract Full Avatar Name

libopenmetaverse uses different possible avatar name formats when passing avatar names. For example, an avatar name can be in one of the following formats:

The following brief LINQ query will help you resolve all these names to a list of two elements:

string avatarName = "Snooky Smexy";
// ...
List<string> name =
    new List<string>(Regex.Matches(avatarName, @"^(?<first>.*?)([\s\.]|$)(?<last>.*?)$")
        .Cast<Match>()
        .ToDictionary(o => new[]
        {
            o.Groups["first"].Value,
            o.Groups["last"].Value
        }).SelectMany(o => new[] {o.Key[0], !string.IsNullOrEmpty(o.Key[1]) ? o.Key[1] : "Resident"}));
Console.WriteLine(name.First());
Console.WriteLine(name.Last());
Console.ReadKey();

where the list name will have the first element set to the first name of the avatar and the last name set to the last name of the avatar (or Resident) if no last name was found.