import re

with open("links.txt", "r") as f:
    for line in f:
        match = re.search(r'https://pubmed.ncbi.nlm.nih.gov/(\d+)/', line)
        if match:
            print(match.group(1))
