How to compare two strings using regex in Python?

PythonServer Side ProgrammingProgramming

We can compare given strings using the following code

Example

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

Output

This gives the output

Strings do not match
raja
Published on 08-Jan-2018 16:54:07
Advertisements