#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?ms)(\n\n+\s+}|\n\n})"
Local $sString = "------------------------------------------------------------------------------" & @CRLF & _
"REGEX to strip all whitelines ABOVE line with single closing curly bracket" & @CRLF & _
"------------------------------------------------------------------------------" & @CRLF & _
"" & @CRLF & _
"```powershell" & @CRLF & _
"Describe {" & @CRLF & _
" Write-Host "As happening with InModuleScope.mdx"" & @CRLF & _
"" & @CRLF & _
" It "Test Export-CSV" {" & @CRLF & _
" Get-ChildItem | Export-CSV -Path $filePath -NoTypeInformation" & @CRLF & _
" $dir = Import-CSV -Path $filePath" & @CRLF & _
" # ..." & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"}" & @CRLF & _
" It "Test Export-Clixml" {" & @CRLF & _
" Get-ChildItem | Export-Clixml -Path $filePath" & @CRLF & _
" $dir = Import-Clixml -Path $filePath" & @CRLF & _
" # ..." & @CRLF & _
"" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
""
Local $sSubst = "\n}"
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