I am very new to python and
I want to match a pattern which comes from a list and if matches return the pattern.
List contains names of areas in a city and I need to find if a area is present in a url like
www.abc.com/category-city_area_name-deal/
city=[AreaName]
I need to match AreaName in the url regardless of underscore present in url. So for me when i search for AreaName in the url, it should match to area_name.
If you want to ignore underscores and upper/lower case, you can try this without using regex:
The
a.replace('_', '').lower()removes all underscores fromaand converts it to lowercase.and then it tests whether
'areaname'is contained within'www.abc.com/category-cityareaname-deal/', which is True.