【发布时间】:2018-08-20 15:19:06
【问题描述】:
如果一个字符串在任何地方只包含字母、数字、空格和点(.)并且没有顺序,我正在尝试开发一个匹配的正则表达式。
像这样:
hello223 3423. ---> True
lalala.32 --->True
.hellohow1 ---> True
0you and me = ---> False (it contains =)
@newye ---> False (it contains @)
With, the name of the s0ng .---> False (it start with ,)
我正在尝试这个,但总是返回匹配:
m = re.match(r'[a-zA-Z0-9,. ]+', word)
有什么想法吗?
另一种表述问题的方法是,有没有字母、数字、点和空格不同的字符?
提前致谢
【问题讨论】:
-
全部还是任何?例如。 “A”会匹配吗?
-
@AlexK。提出问题的其他方式是字母、数字、点和空格是否有任何不同的字符?
标签: python regex python-2.7