python - \Z doesn't match end of string -
i have regex (?p<url>http.{1,}?[\s)\z]) find url ending in \s character, close parenthesis, or end of string, matches first 2 cases.
how match third (end of string)?
\z doesn't work inside character sets - matches z (most features disabled inside character class, including ., +, etc. other character classes work: \w, \d, etc).
want use alternation: (?:[\s)]|\z).
in addition, .{1,}? same .+?, whole pattern can written as
(?p<url>http.+?(?:[\s)]|\z))
Comments
Post a Comment