Thanks all for the replies, those were some helpful info.
@guinness: i know what you mean now, i also looked at the referred threads, processing literal strings first is indeed the correct way, i have tried the method that grabs all the strings and replace them one by one but this method's performance was getting proportionally slow the more literal strings the script contains.
So, i came up with a way to do all the string processing in 1 call, this also works on strings that contain both single and double quote for me so far:
$sTargetDir = "SomeScript_stripped.au3" ;Only works on tidied and stripped scripts
$sScriptContent = FileRead($sTargetDir)
$sScriptContent = Execute('"' & StringRegExpReplace($sScriptContent, "( |, |\x28|\R|\x2C|\x5B)(?<quote>\x22|\x27)(.*?)(\k<quote>)(\R|\x2C|\x26|\x29| |\x3B|\x5D)", '$1" & _ObfConvertString($2$3$4) & "$5') & '"')
ConsoleWrite(@CRLF & $sScriptContent & @CRLF)
Func _ObfConvertString($sfString)
$sBinaryString = StringToBinary($sfString, 4)
$sfResult = 'BinaryToString' & '("' & $sBinaryString & '")'
Return $sfResult
EndFunc
Main part of the above script:
$sScriptContent = Execute('"' & StringRegExpReplace($sScriptContent, "( |, |\x28|\R|\x2C|\x5B)(?<quote>\x22|\x27)(.*?)(\k<quote>)(\R|\x2C|\x26|\x29| |\x3B|\x5D)", '$1" & _ObfConvertString($2$3$4) & "$5') & '"')
@mikell: And i agree with you on the delicacies part, working with string regex is like building the Eiffel tower with toothpicks and duct tape. But regex is pure magic to me