เปรียบเทียบ String ที่กำหนดด้วยโค้ด:
ตัวอย่าง
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
re.search(pattern, string) ค้นหา Pattern ใน String คืน Match Object หรือ None