#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?i)(?=\S)(?<text>(?<comment>(?<open>[#;]+)(?:[^\S\r\n]*)(?<value>.+))|(?<section>(?<open>\[)(?:\s*)(?<value>[^\]]*\S+)(?:[^\S\r\n]*)(?<close>\]))|(?<entry>(?<key>[^=\r\n\[\]]*\S)(?:[^\S\r\n]*)(?<delimiter>:|=)(?:[^\S\r\n]*)(?<value>[^#;\r\n]*))|(?<undefined>.+))(?<=\S)|(?<linebreaker>\r\n|\n)|(?<whitespace>[^\S\r\n]+)"
Local $sString = "; Comment above the section" & @CRLF & _
"Key0=Value0" & @CRLF & _
"[Section 1]" & @CRLF & _
"Key=Value " & @CRLF & _
" [EmptySection]" & @CRLF & _
"Dummy text" & @CRLF & _
";Commented Key=Value" & @CRLF & _
";The following empty lines are ignored" & @CRLF & _
";" & @CRLF & _
" # " & @CRLF & _
" " & @CRLF & _
" [ Section 2 ]#Comment after [section]; " & @CRLF & _
" Key 1 = Value 1" & @CRLF & _
" Key2 = Value 2 and [text in square brackets]" & @CRLF & _
" EmptyKey= " & @CRLF & _
"[];Noname section ignored" & @CRLF & _
" [ Section2 ] Dummy text after section" & @CRLF & _
" Key3 =Value 3 (symbols [;] are included) " & @CRLF & _
" #Key4 = Value 4 has been commented " & @CRLF & _
"" & @CRLF & _
"Dummy text before section [ Sectionnum3 ] " & @CRLF & _
" Key 5 = Value 5 " & @CRLF & _
" Key6 =Value6 "
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
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