#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(\b(?:G,C,D|A,B,C|E,C,D)|(?:[ABCDEFG](?:#|b)?)(?:\/[ABCDEFG]b)?(?:(?:(?:maj|min|sus|add|aug|dim)(?:\d{0,2}(?:#\d{1,2}|sus\d)?)?)|(?:m\d{0,2}(?:(?:maj|add|#)\d{0,2})?)|(?:-?\d{0,2}(?:\([^)]*\)|#\d{1,2})?))?)"
Local $sString = "1er couplet:" & @CRLF & _
"Gm G " & @CRLF & _
" Mon enfant, nue sur les galets" & @CRLF & _
"G D7" & @CRLF & _
" Le vent dans tes cheveux defaits" & @CRLF & _
"Dsus Cmaj" & @CRLF & _
" Comme un printemps sur mon trajet" & @CRLF & _
"C Em" & @CRLF & _
" Un diamant tombé d'un coffret"
Local $sSubst = "[${1}]"
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