Answer the question
In order to leave comments, you need to log in
Is the regex correct?
Information:
There is a certain site where I get data (video). The parsing function works fine if you provide a link in requests.get(url). But I want to use this function elsewhere in the future, so I need a regular expression so that I expect different values from the user, and everything works without interruption.
Description:
There is this link: https://example.com/serial/season-2/episode-3.html and https://example.com/serial/episode-1.html .
That is, the fact is that the links are different, some links do not have the season-X part (instead of X, any number). And the problem with seasons and episodes is that they can reach 200, or 10, different.
url = r'^https://(example\.com)/\w+/(episode-\d+|season-\d+/episode-\d+).html$'
Answer the question
In order to leave comments, you need to log in
Use the question mark quantifier to indicate that some part of the regular expression may or may not be present.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question