【发布时间】:2019-05-08 10:28:56
【问题描述】:
我喜欢为下面的场景写一个正则表达式
正则表达式:?
示例 1
输入:
I got good morning message
输出:
good morning
示例 2
输入
good morning message
输出
good morning
示例 3
输入:
my friend got thank you message from xyz
输出:
thank you
忽略其他细节,如i got、message、my friend got,输出应该包含消息。消息可以是任何东西,不仅是good morning、thank you。
【问题讨论】:
-
可以使用
in操作符来完成为什么要使用regex来使事情复杂化? -
听起来你在追求 NLP。如果是这样,请尝试 NLTK 或 Spacy。
-
不,实际上我只需要使用正则表达式...