I have an array of strings like
urls_parts=['week', 'weeklytop', 'week/day']
And i need to monitor inclusion of this strings in my url, so this example needs to be triggered by weeklytop part only:
url='www.mysite.com/weeklytop/2'
for part in urls_parts:
if part in url:
print part
But it is of course triggered by 'week' too. What is the way to do it right?
OOps, let me specify my question a bit. I need that code not to trigger when url='www.mysite.com/week/day/2' and part='week' The only url needed to trigger on is when the part='week' and the url='www.mysite.com/week/2' or 'www.mysite.com/week/2-second' for example
url_partsand how could you expect the computer can tell apart without tokenizingurl? You need to at least define word boundary before you can match in your way above...or do it regex