Does C# have a String Tokenizer like Java's?

前端 未结 11 1500
日久生厌
日久生厌 2020-12-01 11:31

I\'m doing simple string input parsing and I am in need of a string tokenizer. I am new to C# but have programmed Java, and it seems natural that C# should have a string tok

11条回答
  •  抹茶落季
    2020-12-01 12:23

    _words = new List(YourText.ToLower().Trim('\n', '\r').Split(' ').
                Select(x => new string(x.Where(Char.IsLetter).ToArray()))); 
    

    Or

    _words = new List(YourText.Trim('\n', '\r').Split(' ').
                Select(x => new string(x.Where(Char.IsLetterOrDigit).ToArray()))); 
    

提交回复
热议问题