Python正则表达式匹配没有点的单词 [英] Python regex to match words not having dot

查看:56
本文介绍了Python正则表达式匹配没有点的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想接受具有wild.flower"、pink.flower"、...即.flower"之前的任何单词的模式的字符串,但该单词不应包含点.例如,pink.blue.flower"是不可接受的.任何人都可以帮助如何使用正则表达式在 python 中做到这一点?

I want to accept only those strings having the pattern 'wild.flower', 'pink.flower',...i.e any word preceding '.flower', but the word should not contain dot. For example, "pink.blue.flower" is unacceptable. Can anyone help how to do this in python using regex?

推荐答案

您正在寻找"^\w+\.flower$".

这篇关于Python正则表达式匹配没有点的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆