Say this is my string: http://www.test.com/1/page/
And this is my sub_string: www.test.com/2/page/
Now if I run
sub_string in string
The result will obviously be False because 2 is not in the string. However, I don’t care about that part. The only parts I care about are www.test.com and page. I want only these parts to be checked, and don’t care about what’s in between them. How can I perform a search in that way, so the results would be True?
>Solution :
You can use regex.
import regex as re
test_string="www.test.com/2/page/"
len(re.findall(".*www\.test\.com\/[0-9]\/page\/",test_string))>0
Output:
True