作业帮 > 英语 > 作业

C# 正则表达式的应用,将英语试卷内容截取下来.每一句一个数组.

来源:学生作业帮 编辑:拍题作业网作业帮 分类:英语作业 时间:2024/06/04 01:07:33
C# 正则表达式的应用,将英语试卷内容截取下来.每一句一个数组.
要怎么考虑数字、标点符号、部分中文的复杂性
例如:将一篇英语文章拆分
 My deskmate admires my fluent English very much and I usually feel encouraged by his compliments.
  One day, when we learned the new word “eccentric” in class, we were asked to make a sentence with it. eccentric boy whose clothes never fit him.” .my deskmate’s face turned red.
  Not until then did. powerful in both positive and negative ways. We should avoid hurting... encouraging when we speak.
理解你的意思了
说说我的思路
数字、标点符号、部分中文可以用反向匹配,一句英文一般都是以 逗号、点等结束,那可以用[^\.^,]*?来匹配一句话
重点是找到一句话有哪些结束符号
如果需要我写表达式,
再问: 拆分后:

第一句:My deskmate .... by his compliments.
第二句:One day, .... asked to make a sentence with it.
。。。。。
最后一句:We should .... we speak.
再答: ([^\.]*?)[\.]
获取组1 就可以匹配每一句了,用程序做下处理放入数组吧

若不能解决,请追问,我继续帮你
再问: 如果再加上其他符号断句呢?例如问号,这个或条件怎么加,我是新手,求助!
再答: ([^.?]*?)[.?]
如果想匹配其他符号
一般在两个方括号里加就可以了,如上我又加了个?号