首页 新闻 会员 周边

求一正则表达式的写法!!!!

0
悬赏园豆:50 [已解决问题] 解决于 2009-04-27 02:48

一篇文章取其第一段,既从开头取文本 遇到 ,,.。??!!空格,换行 等符号为结束,如果全文只有一句话,既无 ,,.。??!!空格,换行 等符号则取全文内容

例:

有国外研究机构最近发布报告称,去年全球总共发出了62000000000000邮件,按每封垃圾邮件所产生约0.3克的二氧化碳排放量计算,一年的时间全世界的垃圾邮件就产生了170万吨的二氧化碳。而这些二氧化碳等于开车绕地球160万次,或150万个美国家庭一年的排放量,可见垃圾邮件已威胁到人类的生存并非危言耸听,而是其危害力度已经到了人们不得不重视的地步。

取:有国外研究机构最近发布报告称,

例:

有国外研究机构最近发布报告称
去年全球总共发出了62000000000000邮件
按每封垃圾邮件所产生约0.3克的二氧化碳排放量计算,一年的时间全世界的垃圾邮件就产生了170万吨的二氧化碳。而这些二氧化碳等于开车绕地球160万次,或150万个美国家庭一年的排放量,可见垃圾邮件已威胁到人类的生存并非危言耸听,而是其危害力度已经到了人们不得不重视的地步。

取:有国外研究机构最近发布报告称

wuyou331的主页 wuyou331 | 初学一级 | 园豆:101
提问于:2009-04-17 22:21
< >
分享
最佳答案
0

^[^ ,,.。??!!\r\n]*

匹配出来的第一个就是要的

花生1 | 小虾三级 |园豆:872 | 2009-04-20 12:49
其他回答(3)
0

 

^([0-9a-z\\u4e00-\\u9fa5]+)

 

 

Code
// using System.Text.RegularExpressions;

public Regex regex = new Regex("^([0-9a-z\\u4e00-\\u9fa5]+)",RegexOptions.IgnoreCase);


//// Replace the matched text in the InputText using the replacement pattern
// string result = regex.Replace(InputText,regexReplace);

//// Split the InputText wherever the regex matches
// string[] results = regex.Split(InputText);

//// Capture the first Match, if any, in the InputText
// Match m = regex.Match(InputText);

//// Capture all Matches in the InputText
// MatchCollection ms = regex.Matches(InputText);

//// Test to see if there is a match in the InputText
// bool IsMatch = regex.IsMatch(InputText);

//// Get the names of all the named and numbered capture groups
// string[] GroupNames = regex.GetGroupNames();

//// Get the numbers of all the named and numbered capture groups
// int[] GroupNumbers = regex.GetGroupNumbers();

 

 

黑白之间 | 园豆:859 (小虾三级) | 2009-04-18 04:03
0

([,,.。??!!](.*?)[,,.。??!!]|(.*?)[,,.。??!!]|(.*?))

通过group来取

小眼睛老鼠 | 园豆:2731 (老鸟四级) | 2009-04-18 22:49
0

^\w+

jiaohh | 园豆:205 (菜鸟二级) | 2009-04-20 15:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册