Jump to content

stringregexp 3 digit


Recommended Posts

Edit: StringRegExpReplace not StringRegExp Sorry

With the following code:

#include <ScreenCapture.au3>

DirCreate(@ScriptDir & "\SS\")

For $i = 9 To 10
    Local $sOutput = StringRegExpReplace("Screen" & $i & ".jpg", "([a-zA-Z]+)(\d{1})(\..+)", "${1}00$2$3")
    ConsoleWrite($sOutput & @CRLF)
;~  If Not FileExists(@ScriptDir & "\SS\" & $sOutput) Then
;~      _ScreenCapture_Capture(@ScriptDir & "\SS\" & $sOutput)
;~      ExitLoop
;~  EndIf
Next

I can get it to output,

Screen009.jpg

Screen10.jpg

But I would like:

Screen009.jpg

Screen010.jpg

and if in 100's I would like,

Screen100.jpg so on.

 

Also would there be a better way to execute this than checking 1 to 999? Lets say program was restarted at Screen500.jpg it would start at 500 and next time start at 501 within program?

Below is what I thought of while typing the question above but there might be a better solution to this as well.

#include <ScreenCapture.au3>

$LastScreen = _ScreenSave(9)
MsgBox(), "Test", "Last Screen .jpg saved was " & $LastScreen)

Func _ScreenSave($iLastScreen)
    Local $iLastScreen, $sOutput
    DirCreate(@ScriptDir & "\SS\")

    For $i = $iLastScreen To 10
        $sOutput = StringRegExpReplace("Screen" & $i & ".jpg", "([a-zA-Z]+)(\d{1})(\..+)", "${1}00$2$3")
        If Not FileExists(@ScriptDir & "\SS\" & $sOutput) Then
            _ScreenCapture_Capture(@ScriptDir & "\SS\" & $sOutput)
            Return $i
        EndIf
    Next
EndFunc
Edited by Rogue5099
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...