如何使用re.search匹配其中一个关键字并在之前和之后找到两个单词?
假设我有客户的评论,我想找出客户是否为她买了礼物:孙子,孙女,孙女,孙女,儿子,女儿,侄女,侄子。 我可以使用以下代码进行操作,但是我不确定如何在一个re.search中搜索所有这些关键词?谢谢。 re.search('(\ w+\ s+\ w+)\ s+s+大女儿\ s+(\ w+\ s+\ w+)',评论[“ body”] [iii])
Say that I have a comment from customer and I want to find out whether customer bought the gift for her: grandson, granddaughter, grand son, grand daughter, son, daughter, niece, nephew.
I can do one with the following code, but I'm not sure how to search all these key words in one re.search? Thanks.
re.search('(\w+\s+\w+)\s+grand daughter\s+(\w+\s+\w+)', review["Body"][iii])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论