#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(### EXAMPLE ([0-9|[0-9]+))\n(```\n(```|```ps|```posh|```powershell)\n```\n)\n([\s\S]*?)\\`\\`\\`(\n\n|\n)([\s\S]*|\n)"
Local $sString = "### EXAMPLE 123" & @CRLF & _
"```" & @CRLF & _
"```powershell" & @CRLF & _
"```" & @CRLF & _
"" & @CRLF & _
"$powershellVersion = '6 and lower'" & @CRLF & _
"$description = 'custom code fencing example WITH markdown description'" & @CRLF & _
"$names | Foreach-Object {} {" & @CRLF & _
" write-host 'indentation is respected'" & @CRLF & _
" Write-Host 'enormously long lines should not get cut off by our PlatyPS friends, ftw'" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"$emptyNewlinesInCode = $True" & @CRLF & _
"\`\`\`" & @CRLF & _
"" & @CRLF & _
"The description would continue after first closing code fence." & @CRLF & _
"" & @CRLF & _
"This solution:" & @CRLF & _
"" & @CRLF & _
"- respects indentation" & @CRLF & _
"- will treat description as markdown" & @CRLF & _
"- seems close to what comes natural" & @CRLF & _
"" & @CRLF & _
"With this solution, the description itself could even contain code blocks:" & @CRLF & _
"" & @CRLF & _
"\`\`\`js" & @CRLF & _
"$var = docusaurus.New($config);" & @CRLF & _
"\`\`\`" & @CRLF & _
"" & @CRLF & _
"Pretty cool and the console becomes more readable too IMO, at least" & @CRLF & _
"you now see where the code ends and the explanation begins" & @CRLF & _
"" & @CRLF & _
"\`\`\`" & @CRLF & _
"$unMonicked = "should stay unmonicked, in other words powershell should not be added"" & @CRLF & _
" $indentationRespected = $True" & @CRLF & _
"$theBadNews - "that PlatyPS seems to cut off this line if a ." & @CRLF & _
"is detected, wtf"" & @CRLF & _
"\`\`\`"
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