#6630: allow customizing flags for compiling string.Template.idpattern.
diff --git a/Lib/string.py b/Lib/string.py
index 5089193..defe894 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -81,7 +81,7 @@
                 'delim' : _re.escape(cls.delimiter),
                 'id'    : cls.idpattern,
                 }
-        cls.pattern = _re.compile(pattern, _re.IGNORECASE | _re.VERBOSE)
+        cls.pattern = _re.compile(pattern, cls.flags | _re.VERBOSE)
 
 
 class Template(metaclass=_TemplateMetaclass):
@@ -89,6 +89,7 @@
 
     delimiter = '$'
     idpattern = r'[_a-z][_a-z0-9]*'
+    flags = _re.IGNORECASE
 
     def __init__(self, template):
         self.template = template