python 3.x - Regex repeating substring -


i trying simple true/false test see if string matches regular expression:

import re  sentence = "eee"  if sentence == r"e*":     print(true) else:     print(false) 

how can come true?

try following:

import re  sentence = "eee" matches = sentence.match("e") !== "none"  if matches:     print(true) else:     print(false) 

the .match method returns "none" if regex not match. variable matches returns true or false according if matched.


Comments

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -