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
Post a Comment