我正在研究一个我想从时髦的字符串中获取用户名的作品。
例子:
- a> Jacob+Delta+2012_Bio
- b> Diana_Bio_smith_2011
- c> Bio_5+10+2012+Steve00
我想解析字符串,并删除特殊字符和某些常用词,如 Bio、Year 和 Dates,并得到如下所示的结果字符串。
- a> Delta 的 Jacob 想要将两者都放在一个数组中。
- B>戴安娜·史密斯
- c>史蒂夫
以下是我正在尝试的事情:
    class TestStringSplit
        {
            static void Main()
            {
 char[] delimiterChars = { ' ', ',', '.', ':', '\t', '_','+','-' };
                string text = "Jacob+Delta+2012_Bio";
                System.Console.WriteLine("Original text: '{0}'", text);
                string[] words = text.Split(delimiterChars);
                System.Console.WriteLine("{0} words in text:", words.Length);
                foreach (string s in words)
                {
                    System.Console.WriteLine(s);
                }
            }
        }