#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?i)([\s\S]+)\s*primary\s+key\s*\(\s*`([a-z]\w*)`\s*\)\s*(,\s*unique\s+key\s+uniq_\w+\s*\(`([a-z]\w*)`\))?(,\s*key\s+idx_\w+\s*\((\s*,?\s*`([a-z]\w*)`\s*)+\)\s*)+"
Local $sString = "`id` INT (11) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'primary'," & @CRLF & _
"`stu_name` VARCHAR (10) NOT NULL DEFAULT '' COMMENT 'username'," & @CRLF & _
"`stu_class` VARCHAR (10) NOT NULL DEFAULT '' COMMENT 'class'," & @CRLF & _
"`stu_num` INT (11) NOT NULL DEFAULT '0' COMMENT 'study number'," & @CRLF & _
"`stu_score` SMALLINT UNSIGNED NOT NULL DEFAULT '0' COMMENT 'total'," & @CRLF & _
"`tuition` DECIMAL (5, 2) NOT NULL DEFAULT '0' COMMENT 'fee'," & @CRLF & _
"`phone_number` VARCHAR (20) NOT NULL DEFAULT '0' COMMENT 'mobile'," & @CRLF & _
"`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'record created time'," & @CRLF & _
"`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'record updated time'," & @CRLF & _
"`status` TINYINT NOT NULL DEFAULT '1' COMMENT 'some comment'," & @CRLF & _
"PRIMARY KEY (`id`)," & @CRLF & _
"UNIQUE KEY uniq_stu_num (`stu_num`)," & @CRLF & _
"KEY idx_stu_score (`stu_score`)," & @CRLF & _
"KEY idx_update_time_tuition (`update_time`, `tuition`)"
Local $sSubst = "\2"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm