Я предполагаю, что вход представляет собой список предложений, содержащих URL. Надеюсь, это поможет.
msg =['hello there http://google.com/p/BvluRHRhN16/ this is a test',
'hello there https://www.instagram.com/p/BvluRHRhN16/',
'hello there www.instagram.com/p/BvluRHRhN16/ this is a test',
'hello there https://www.instagram.net/p/BvluRHRhN16/ this is a test'
]
for m in msg:
ms = re.findall('(http.*instagram.+\/p.+|www.*instagram.+\/p.+)',m)
print(ms)
Отредактированное регулярное выражение:
ms = re.findall('(http.*instagram\.com\/p.+\/|www.*instagram\.com\/p.+\/)',m)