Jump to content
Sign in to follow this  

Help with StringRegExp!

Recommended Posts

How can I use StringRegExp to detect this format of string: [Drive]\[Folder1]\[Folder2]\[...]\[Filename][.ext1][.ext2(exe, bat)]

Sample paths :


Thanks alot! :idea:

Edited by logmein

Share this post

Link to post
Share on other sites

your regular expression would be something like this:


First group is the drive, second group is the path, third group is the filename.

You'll have to parse the path using stringexplode on the backslash "\" if you want to further break it down.

Edited by JRowe

Share this post

Link to post
Share on other sites

Cause I'm tired and have to stay awake:

#include <Array.au3> ; Only for _ArrayDisplay()

Global $aStrings[4] = ["C:\British\SpitFire.html.exe", _
    "C:\Luftwaffe\Stuka.txt.exe", _
    "D:\Soviet\Sturmovik.doc.bat", _

Global $sPatt = "(?i)([[:alpha:]]:)(?:\\)(.+)(?:\\)(.+\.(?:exe|bat)\Z)", $aRET

For $n = 0 To UBound($aStrings) - 1
    $aRET = StringRegExp($aStrings[$n], $sPatt, 3)
    If IsArray($aRET) Then
        _ArrayDisplay($aRET, $n & ": $aRET")
        ConsoleWrite($n & ": Failed: @error = " & @error & "; @extended = " & @extended & @LF)


Edit: Forgot the alternative (exe|bat)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...