I want to use RegExp to analyze script
Switch $sStringChecking Case '1' $sTestString = 'test1' Case '2' $sTestString = 'test1' $sTestString = 'test2' Case '3' $sTestString = 'test1' $sTestString = 'test2' $sTestString = 'test3' Case '4' $sTestString = 'test1' $sTestString = 'test2' $sTestString = 'test3' $sTestString = 'test4' case Else $sTestString = 'else' EndSwitch
And I use somethnig like that
AutoIt
#include <array.au3> #include <string.au3> $sString = "" $sString &= "Switch $sStringChecking" & @CRLF $sString &= " Case '1'" & @CRLF $sString &= " $sTestString = 'test1'" & @CRLF $sString &= " Case '2'" & @CRLF $sString &= " $sTestString = 'test1'" & @CRLF $sString &= " $sTestString = 'test2'" & @CRLF $sString &= " Case '3'" & @CRLF $sString &= " $sTestString = 'test1'" & @CRLF $sString &= " $sTestString = 'test2'" & @CRLF $sString &= " $sTestString = 'test3'" & @CRLF $sString &= " Case '4'" & @CRLF $sString &= " $sTestString = 'test1'" & @CRLF $sString &= " $sTestString = 'test2'" & @CRLF $sString &= " $sTestString = 'test3'" & @CRLF $sString &= " $sTestString = 'test4'" & @CRLF $sString &= " Case Else" & @CRLF $sString &= " $sTestString = 'else'" & @CRLF $sString &= "EndSwitch" & @CRLF $aResult = StringRegExp ( $sString, "(?is)(case.*?)case" ,3) _ArrayDisplay($aResult,'$aResult')
And as a result I have that
[0]|Case '1'$sTestString = 'test1'[1]|Case '3'$sTestString = 'test1'$sTestString = 'test2'$sTestString = 'test3'
I trying to have that result
[0]|Case '1'$sTestString = 'test1'[1]|Case '2'$sTestString = 'test1'$sTestString = 'test2'[2]|Case '3'$sTestString = 'test1'$sTestString = 'test2'$sTestString = 'test3'[3]|Case '4'$sTestString = 'test1'$sTestString = 'test2'$sTestString = 'test3'$sTestString = 'test4'
Actualy I parsing $sString something like that
AutoIt
#include <array.au3> #include <string.au3> $sString = "" $sString &= "Switch $sStringChecking" & @CRLF $sString &= " Case '1'" & @CRLF $sString &= " $sTestString = 'test1'" & @CRLF $sString &= " Case '2'" & @CRLF $sString &= " $sTestString = 'test1'" & @CRLF $sString &= " $sTestString = 'test2'" & @CRLF $sString &= " Case '3'" & @CRLF $sString &= " $sTestString = 'test1'" & @CRLF $sString &= " $sTestString = 'test2'" & @CRLF $sString &= " $sTestString = 'test3'" & @CRLF $sString &= " Case '4'" & @CRLF $sString &= " $sTestString = 'test1'" & @CRLF $sString &= " $sTestString = 'test2'" & @CRLF $sString &= " $sTestString = 'test3'" & @CRLF $sString &= " $sTestString = 'test4'" & @CRLF $sString &= " Case Else" & @CRLF $sString &= " $sTestString = 'else'" & @CRLF $sString &= "EndSwitch" & @CRLF StringReplace($sString," Case '"," Case '") $sString = StringReplace($sString," Case '"," CaseCase '",-(@extended-1)) $aResult = StringRegExp ( $sString, "(?is)(case.*?)case" ,3) _ArrayDisplay($aResult,'$aResult')
but I think
Maybe this can be done only with StringRegExp without StringReplace ?