diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py index b3a0526874..1dc30a3960 100644 --- a/django/contrib/admindocs/utils.py +++ b/django/contrib/admindocs/utils.py @@ -144,7 +144,11 @@ unnamed_group_matcher = _lazy_re_compile(r'\(') def replace_metacharacters(pattern): """Remove unescaped metacharacters from the pattern.""" - return pattern.replace('^', '').replace('$', '').replace('?', '') + return re.sub( + r'((?:^|(?