C#: 从英文句子中提取单词

HTML Editor有个spell check功能,需要对整篇英文文章进行单词验证,在后台写一个Js web service for c#,用于从文章中提取单词,提出单词的函数如下:

preivate void getLetter(string ptext) {
            char[] separators = { ' ', ',', '?', ':', '!', '"', ';', '(', ')', '.', ''', '_', '—','-' };
            int startpos=0;
            int endpos=0;
            do
            {
                endpos=mystring.IndexOfAny(separators,startpos);
                if ( endpos==-1 ) endpos=ptext.Length;
                if ( endpos!=startpos )
                    Response.Write(ptext.Substring( startpos,(endpos-startpos)) + "<br/>");
                startpos=(endpos+1);
            }
            while(startpos<ptext.Length);
}

在asp.net 2.0环境下测试成功。

引用通告地址: 点击获取引用地址
评论: 0 | 引用: 0 | 阅读: 1524 | 打印 | 打包 | 转发
发表评论
昵 称: 密 码:
网 址: 邮 箱:
验证码: 验证码图片 选 项:
头 像:
内 容:
  • 粗体
  • 斜体
  • 下划线
  • 插入图像
  • 超链接
  • 电子邮件
  • 插入引用