subText学习心得一(获取汉字第一个拼音)

近期在学习subtext,在Subtext.Framework中很类的写法,都很经典,值的我们深入去学习。

在Subtext.Framework中Entries.cs提供了"获取汉字第一个拼音",在后期会不断和大家一起分享学习心得。

在使用下列代码时,请引用

using System.Text;

using System.Text.RegularExpressions;

 static string RemoveNonWordCharacters(string text)
        
{
            
string txt = getSpells(text);//中文转换成拼音
            Regex regex = new Regex(@"[\w\d\.\- ]+", RegexOptions.Compiled);
            MatchCollection matches 
= regex.Matches(txt);
            
string cleansedText = string.Empty;

            
foreach (Match match in matches)
            
{
                
if (match.Value.Length > 0)
                
{
                    cleansedText 
+= match.Value;
                }

            }

            
return cleansedText;
        }


         
获取汉字第一个拼音
    }
          
posted @ 2008-07-21 09:42  编程入门  阅读(383)  评论(0编辑  收藏  举报