#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?:^|\G)( {4}|\t)"
Local $sString = "<?php" & @CRLF & _
"" & @CRLF & _
"class SomeClass" & @CRLF & _
"{" & @CRLF & _
" var $property = 1;" & @CRLF & _
"" & @CRLF & _
" function double(int $x)" & @CRLF & _
" {" & @CRLF & _
" $result = $x + $x;" & @CRLF & _
" // line already indented with tabs" & @CRLF & _
" // line started with tab, but followed with spaces" & @CRLF & _
" // line has 4 spaces in the middle" & @CRLF & _
" // line endings with 4 spaces " & @CRLF & _
" return $result;" & @CRLF & _
" }" & @CRLF & _
"}"
Local $sSubst = "\t"
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