Local Const $ASCII_ACK = Chr(6)
ConsoleWrite('$vVar = 100 ; Variable inside quotes.' & @CRLF)
ConsoleWrite('$MB_SYSTEMMODAL ; Variable inside quotes.' & @CRLF)
$sData = FileRead(@ScriptFullPath)
; Replace variables inside quotes with ACK$vVariableACK.
; $sData = StringRegExpReplace($sData, '(?m)^((?:[^''";]*([''"]).*?\2)*[^;]*)(?:;?[^\r\n]*)', '\1') ; By ProgAndy. http://www.autoitscript.com/forum/topic/108728-stripcomments/#entry765712
$sData = StringRegExpReplace($sData, '(?m)^((?:[^''"]*([''"])(?:[^$]*?(\$\w+))*([''"])[^;]*)(?:;?[^\r\n]*)', $ASCII_ACK & '\1' & $ASCII_ACK) ; Comment
ConsoleWrite($sData & @CRLF)
The code isn't working as the regular expression is poorly designed. But I was wondering whether it was possible to wrap $VARNAME (dollar+ A-Za-z0-9) with ACK. As I'm replacing variables in a script and it's catching those in a quoted string. So if I use a lookahead and lookbehind for x6 then this won't happen.