#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^(basedir[ ]*=[ ]*")(.)(:[\/\\])([a-zA-Z0-9]*)([\/\\]?.*)$"
Local $sString = "[mysqld]" & @CRLF & _
"#skip-innodb" & @CRLF & _
"" & @CRLF & _
"# The TCP/IP Port the MySQL Server will listen on" & @CRLF & _
"port=3306" & @CRLF & _
"max_allowed_packet=16M" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"#Path to installation directory. All paths are usually resolved relative to this." & @CRLF & _
"#basedir="C:/Program Files/MySQL/MySQL Server 5.1/"" & @CRLF & _
"basedir="C:/MySQL/"" & @CRLF & _
"" & @CRLF & _
"#Path to the database root" & @CRLF & _
"#datadir="C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.1/Data/"" & @CRLF & _
"datadir="C:/MySQLData/"" & @CRLF & _
"" & @CRLF & _
"# The default character set that will be used when a new schema or table is" & @CRLF & _
"# created and no character set is defined" & @CRLF & _
"default-character-set=utf8"
Local $sSubst = "$1Z$3Here$5"
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