Use \d+ (without brackets) according to the literal trait + numbers:
response = re.search(r'^(http://)?(www\.)?(vimeo\.com/)?(\d+)', embed_url)
Result:
>>> re.search(r'^(http://)?(www\.)?(vimeo\.com/)?(\d+)', embed_url).group(4) '52422837'
You used a group of characters ( [...] ) where it was not necessary. The pattern [\/\d+] matches exactly one of / , + or a digit.
source share