第1个回答 2009-06-18
每个单词后都有一个空格,所以就可以将文章以空格为分隔点分开,然后存到数组中,最后在打印出来就可以了
string a = "sadh lkasjd alksdj你的文章";
string[] Arr = a.Split[" "];\\将文章以空格为分隔点分开,然后存到数组中
for (int i = 0; i <= Arr.Length - 1; i++)
{
Console.WriteLine(Arr[i]); //打印
}
第2个回答 2009-06-17
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string strSource = " I am a chinese.So i love China.......";
MatchCollection matches = Regex.Matches(strSource, @"(([\w]+)|([\.]{1})(?=[^\.]{1})|([\.]{1})(?=[\.]{6})|([\.]{6,6}))");
for (int i=0;i<matches.Count;i++)
{
Console.WriteLine(matches[i].Groups[1].Value);
}
Console.ReadKey();
}
}
}本回答被提问者采纳
第3个回答 2009-06-17
1、最好使用正则表达式。
2、用split函数,先分离所有的空格。然后遍历数组,每个元素判断一下,标点,如果存在标点两边的内容要变成2个单词。
第4个回答 2009-06-17
string a = "sadh lkasjd alksdj你的文章";
string[] Arr = a.Split[" "];
for (int i = 0; i <= Arr.Length - 1; i++)
{
Console.WriteLine(Arr[i]); //这里是单词的输出程序
}