冲动的大树 发表于 2020-2-7 19:17

求一个字符串相关的正则表达式

本帖最后由 冲动的大树 于 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的句子。括号,___也别漏下,有些句子是以感叹号和问号结尾,中间还有’或“号。

ymhld 发表于 2020-2-7 21:23

冲动的大树 发表于 2020-2-7 21:04
谢谢,你这个最好。就还有一点补充,结束标志那能否加上换行符。有些句子直接用换行符结尾了。

A.I ...

[^\.\?!]+\slike\s[^\.\?!]+?[\.\?!\n]

能发个全的结果?不知道你这里都有啥句子

庞晓晓 发表于 2020-2-7 19:30

goldli 发表于 2020-2-7 19:51

(+like\s++[\.!])

ymhld 发表于 2020-2-7 20:43

本帖最后由 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.

冲动的大树 发表于 2020-2-7 21:04

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:12

本帖最后由 哈哈衬 于 2020-2-7 21:14 编辑

[^.]*\blike\b.*?[.?!]




ymhld 发表于 2020-2-7 21:15

冲动的大树 发表于 2020-2-7 21:04
谢谢,你这个最好。就还有一点补充,结束标志那能否加上换行符。有些句子直接用换行符结尾了。

A.I ...

是每个句子一行吗?

黑色蓝柠檬 发表于 2020-2-7 21:19

本帖最后由 黑色蓝柠檬 于 2020-2-7 21:23 编辑

.[\w\s']+ like [\w\s]+\n|[\w\s'()]+ like [\w\s()]+[.?!]

不苦小和尚 发表于 2020-2-7 21:30

本帖最后由 不苦小和尚 于 2020-2-7 21:33 编辑

楼上的都不完整,我这个比较全
(+\b\w*like\w*\b+[\.|!|\r])
页: [1] 2
查看完整版本: 求一个字符串相关的正则表达式