如何在python中使用正则表达式比较两个字符串?

我们可以使用以下代码比较给定的字符串

示例

import re
s1 = 'Pink Forest'
s2 = 'Pink Forrest'
if bool(re.search(s1,s2))==True:
   print 'Strings match'
else:
   print 'Strings do not match'

输出结果

这给出了输出

Strings do not match