Jump to content

Recommended Posts

Posted (edited)

Perhaps someone would benefit off this.  I made heavy use of the Help file example.

Only question I have here, is is there a better way to do the Regex for finding "error|ERROR|Error" in the source string?  Thx

Example7zPwd()

Func Example7zPwd()
    ;-- Local $iPID = Run(@ComSpec & " /c DIR Example.au3", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $iPID = Run(@ComSpec & " /c 7za t -pmasale myzip.zip ", "c:\files\testing", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $sOutput = ""
    Local $myError = 0
    ConsoleWrite("$myError:" & $myError & @CRLF)

    While 1
        $sOutput = StdoutRead($iPID)
        If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
            ExitLoop
        EndIf
        MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput, 5)


        If StringRegExp($sOutput, '\b(error|ERROR|[Ee]rror)\b', 0) Then $myError = $myError + 1
        ;ConsoleWrite("$sOutput: " & $sOutput & @CRLF)
        ConsoleWrite("$myError: " & $myError & @CRLF)


    WEnd

    While 1
        $sOutput = StderrRead($iPID)
        If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
            ExitLoop
        EndIf

        MsgBox($MB_SYSTEMMODAL, "Stderr Read:", $sOutput, 15)


    WEnd

    ConsoleWrite("$myError: " & $myError & @CRLF)

    If $myError > 0 Then
        MsgBox(64, "An Error Occurred", "The upgrade may be incomplete. An error occurred")
    EndIf

If StringRegExp($sOutput, '\b(error|ERROR|[Ee]rror)\b', 0) Then Is the Regex here optimized?

 

 

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Posted (edited)

Thx for the rapid response!

http://www.regexr.com/ tested it here.  Didn't work.

Tested with (?i)\bthe\b - added an extra " The " to the sample text.  No match found. Ideas? 

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Posted

Hmm, thx. Seems that Regex101 works better than my soon-to-be-previously-preferred site... Thx.  It works as expected.  :) 

Skysnake

Why is the snake in the sky?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...