如何将以下字符串拆分为单词
字符串exp=price+10*discount-30
进入
string[]words={'价格',折扣'}
最佳答案
您可以使用正则表达式匹配单词,然后得到结果。
示例:
// This is the input string.
string input = "price+10*discount-30";
var matches = Regex.Matches(input, @"([a-z]+)", RegexOptions.IgnoreCase | RegexOptions.Multiline);
foreach (var match in matches)
{
Console.WriteLine(match);
}
Console.ReadLine();
关于c# - 如何在 C# 中将字符串拆分为单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13821252/