0
Regex in python
i have learnt a lot about the regex and patterns in python but i can't do it i understood that if i want to make a pattern i have to do it like this pattern=r"blabla" i tried it on pycharm on pc put it didn't work the code was like that import re pat=r"abcd" i ="abcd" if re.match(pat,i): print "it works " else: print"smthg is wrong" the output was always "smthg is wrong" what did i miss?!!
3 Respostas
+ 1
Maybe you forgot to write parentheses for the print function.
Try it:
import re
pat = r"abcd"
i = "abcd"
if re.match(pat,i):
print ("it works ")
else:
print ("smthg is wrong")
+ 1
try to use search method:
if re.search(pat, i)
0
don't think so
cuz i tried it in many ways but always the same result