# see tests/scan.l
text = text.replace(r'{WS}[[:blank:]]+', '{WS}')
-text = text.replace(r'{WS}([[:blank:]]+)', '{WS}')
+text = text.replace(r'{WS}(?:[[:blank:]]+)', '{WS}')
text = text.replace(r'{OPTWS}[[:blank:]]*', '{OPTWS}')
-text = text.replace(r'{OPTWS}([[:blank:]]*)', '{OPTWS}')
+text = text.replace(r'{OPTWS}(?:[[:blank:]]*)', '{OPTWS}')
text = text.replace(r'{NOT_WS}[^[:blank:]\r\n]', '{NOT_WS}')
-text = text.replace(r'{NOT_WS}([^[:blank:]\r\n])', '{NOT_WS}')
+text = text.replace(r'{NOT_WS}(?:[^[:blank:]\r\n])', '{NOT_WS}')
text = text.replace(r'{NL}\r?\n', '{NL}')
-text = text.replace(r'{NL}(\r?\n)', '{NL}')
+text = text.replace(r'{NL}(?:\r?\n)', '{NL}')
text = text.replace(r'{NAME}([[:alpha:]_][[:alnum:]_-]*)', '{NAME}')
-text = text.replace(r'{NAME}(([[:alpha:]_][[:alnum:]_-]*))', '{NAME}')
+text = text.replace(r'{NAME}(?:([[:alpha:]_][[:alnum:]_-]*))', '{NAME}')
text = text.replace(r'{NOT_NAME}[^[:alpha:]_*\n]+', '{NOT_NAME}')
-text = text.replace(r'{NOT_NAME}([^[:alpha:]_*\n]+)', '{NOT_NAME}')
+text = text.replace(r'{NOT_NAME}(?:[^[:alpha:]_*\n]+)', '{NOT_NAME}')
text = text.replace(r'{SCNAME}{NAME}', '{SCNAME}')
-text = text.replace(r'{SCNAME}({NAME})', '{SCNAME}')
+text = text.replace(r'{SCNAME}(?:{NAME})', '{SCNAME}')
text = text.replace(r'{ESCSEQ}(\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2}))', '{ESCSEQ}')
-text = text.replace(r'{ESCSEQ}((\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2})))', '{ESCSEQ}')
+text = text.replace(r'{ESCSEQ}(?:(\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2})))', '{ESCSEQ}')
text = text.replace(r'{FIRST_CCL_CHAR}([^\\\n]|{ESCSEQ})', '{FIRST_CCL_CHAR}')
-text = text.replace(r'{FIRST_CCL_CHAR}(([^\\\n]|{ESCSEQ}))', '{FIRST_CCL_CHAR}')
+text = text.replace(r'{FIRST_CCL_CHAR}(?:([^\\\n]|{ESCSEQ}))', '{FIRST_CCL_CHAR}')
text = text.replace(r'{CCL_CHAR}([^\\\n\]]|{ESCSEQ})', '{CCL_CHAR}')
-text = text.replace(r'{CCL_CHAR}(([^\\\n\]]|{ESCSEQ}))', '{CCL_CHAR}')
+text = text.replace(r'{CCL_CHAR}(?:([^\\\n\]]|{ESCSEQ}))', '{CCL_CHAR}')
text = text.replace(r'{CCL_EXPR}("[:"^?[[:alpha:]]+":]")', '{CCL_EXPR}')
-text = text.replace(r'{CCL_EXPR}(("[:"^?[[:alpha:]]+":]"))', '{CCL_EXPR}')
+text = text.replace(r'{CCL_EXPR}(?:("[:"^?[[:alpha:]]+":]"))', '{CCL_EXPR}')
text = text.replace(r'{LEXOPT}[aceknopr]', '{LEXOPT}')
-text = text.replace(r'{LEXOPT}([aceknopr])', '{LEXOPT}')
+text = text.replace(r'{LEXOPT}(?:[aceknopr])', '{LEXOPT}')
text = text.replace(r'{M4QSTART}"[""["', '{M4QSTART}')
-text = text.replace(r'{M4QSTART}("[""[")', '{M4QSTART}')
+text = text.replace(r'{M4QSTART}(?:"[""[")', '{M4QSTART}')
text = text.replace(r'{M4QEND}"]""]"', '{M4QEND}')
-text = text.replace(r'{M4QEND}("]""]")', '{M4QEND}')
+text = text.replace(r'{M4QEND}(?:"]""]")', '{M4QEND}')
# we can only calculate column numbering once all substitutions done
i = 0