Jump to content
Sign in to follow this  

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

I can get it to output,



But I would like:



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
Edited by Rogue5099

Share this post

Link to post
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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.