求一个字符串相关的正则表达式
本帖最后由 冲动的大树 于 2020-2-7 22:54 编辑我是老师,想从很多英文试卷中找出含有某个单词的整个句子,供学生参考语境和搭配。
比如
There are many online shopping sites. This is very (46) _______. Thingslike CDs, books and DVDs sell well online. But it is quite different to sellfood online because people like to see food with their own eyes. It is veryimportant for people to buy fresh fruit and vegetables. Customers like to choosetheir food (47) _______ its color. They also want to touch and smell it. Butsome people like to go the same shop to buy food because they think the foodthere has a very good quality. So if the food is always good, they may alsofeel comfortable buying it online.
从这段中找出每个含有like的句子。括号,___也别漏下,有些句子是以感叹号和问号结尾,中间还有’或“号。
冲动的大树 发表于 2020-2-7 21:04
谢谢,你这个最好。就还有一点补充,结束标志那能否加上换行符。有些句子直接用换行符结尾了。
A.I ...
[^\.\?!]+\slike\s[^\.\?!]+?[\.\?!\n]
能发个全的结果?不知道你这里都有啥句子 (+like\s++[\.!]) 本帖最后由 ymhld 于 2020-2-7 20:44 编辑
[^\.\?!]+\slike\s[^\.\?!]+[\.\?!]
共找到 3 处匹配:
But it is quite different to sellfood online because people like to see food with their own eyes.
Customers like to choosetheir food (47) _______ its color.
Butsome people like to go the same shop to buy food because they think the foodthere has a very good quality. ymhld 发表于 2020-2-7 20:43
[^\.\?!]+\slike\s[^\.\?!]+[\.\?!]
共找到 3 处匹配:
But it is quite different to sellfood online...
谢谢,你这个最好。就还有一点补充,结束标志那能否加上换行符。有些句子直接用换行符结尾了。
A.I'd like some cake
B.the cake's no good
C.I love the cake very much
D.help yourself to some cake
二、词汇运用
A.用方框中所给单词的适当形式填空。每词限用一次。
1.It __harms__our eyes to read in the sun. 本帖最后由 哈哈衬 于 2020-2-7 21:14 编辑
[^.]*\blike\b.*?[.?!]
冲动的大树 发表于 2020-2-7 21:04
谢谢,你这个最好。就还有一点补充,结束标志那能否加上换行符。有些句子直接用换行符结尾了。
A.I ...
是每个句子一行吗? 本帖最后由 黑色蓝柠檬 于 2020-2-7 21:23 编辑
.[\w\s']+ like [\w\s]+\n|[\w\s'()]+ like [\w\s()]+[.?!]
本帖最后由 不苦小和尚 于 2020-2-7 21:33 编辑
楼上的都不完整,我这个比较全
(+\b\w*like\w*\b+[\.|!|\r])
页:
[1]
2