I'm been programming Java for a long time and recently I've started Python but there's something I can't figure out
import re
test_string = "1989 1989"
matched = re.match("\\d+", test_string)
print(bool(matched))
I'm expecting it to return false, however it returns true. basically I'm just looking for the counterpart of String.matches() in java... I thought maybe you could help me out! thank you in advance
rbefore it.r"\\d+"and it will work as you expected.'\\d+'is entirely correct; using raw strings, which is a good recommendation, would mean usingr'\d+', notr'\\d+'. But that won’t solve OP’s problem.rbefore string will make it search for "\" symbol also, hence will return false.String.matches()does if the actual question is that.