数字我发现这个代码来获得一个字符串的所有单词,查找所有单词,而不使用正则表达式
static string[] GetWords(string input)
{
MatchCollection matches = Regex.Matches(input, @"\b[\w']*\b");
var words = from m in matches.Cast<Match>()
where !string.IsNullOrEmpty(m.Value)
select TrimSuffix(m.Value);
return words.ToArray();
}
static string TrimSuffix(string word)
{
int apostrapheLocation = word.IndexOf('\'');
if (apostrapheLocation != -1)
{
word = word.Substring(0, apostrapheLocation);
}
return word;
}
- 请介绍有关的代码。
- 我怎样才能不数字的话吗?
英语纠错:你大概的意思:请描述一下代码的功能和/或它是如何工作的。 “描述”是不合语法的,过于模糊。 – 2011-04-22 11:43:37
@Robin Green谢谢,我是英语新手。 – Shahin 2011-04-22 11:47:46