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

How to show in django cms breadcrumbs full path? -

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -