#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)((^|\s)#(.*)$)|(^\n)|(\n(\s|)+#(.*)$)|([\n\s]+#.*)|([\n\s]{2,}$)"
Local $sString = "#This RegEx removes inline comments and blank lines in python code!" & @CRLF & _
"" & @CRLF & _
"# This will save you tokens and time when using GPT to help code and debug." & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"import requests" & @CRLF & _
"import os" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"#Define vars" & @CRLF & _
"def add(a, b):" & @CRLF & _
" return a + b" & @CRLF & _
"# print results" & @CRLF & _
"result = add(2, 3)" & @CRLF & _
"print(result) # Output: 5" & @CRLF & _
"print("Complete")" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
""
Local $sSubst = ""
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