I am trying to compare string with regex in python as follows,
#!/usr/bin/env python3
import re
str1 = "Expecting property name: line \d+ column \d+ (char \d+)"
str2 = "Expecting property name: line 3 column 2 (char 44)"
print(re.search(str1,str2))
if re.search(str1,str2) :
print("Strings are same")
else :
print("Strings are different")
I always get following output
None
Strings are different
I am not able to understand what is wrong here.
Can someone suggest/point me what is wrong with this ?
str1 = r"Expecting property name: line \d+ column \d+ \(char \d+\)"