Home > Back-end >  Python link scraper regex works when only searching for 1 extension type, but fails when matching mo
Python link scraper regex works when only searching for 1 extension type, but fails when matching mo

Time:02-02

This is the test link I am using for this project: enter image description here

CodePudding user response:

Another way to solve this is to have non capturing groups with ?:

pattern = re.compile(r'http[s]?://[^\s] \.(?:mp3|flac|wav)')

See here.

  • Related