Home > Software design >  Match text between parenthesis that end with .md
Match text between parenthesis that end with .md

Time:11-14

I need to get the text inside the parenthesis where the text ends with .md using a regex (if you know another way you can say it) in python.

Original string: [Romanian (Romania)](books/free-programming-books-ro.md)

Expected result: books/free-programming-books-ro.md

CodePudding user response:

This should work:

import re
s = '[Romanian (Romania)](books/free-programming-books-ro.md)'
result = re.findall(r'[^\(] \.md(?=\))',s)

['books/free-programming-books-ro.md']
  • Related