Jump to content

Filter file name with StringRegExp?


Recommended Posts

Actually use 

((.*)(?=\\)(\\))(stripped_v)(.*)(.au3)$

That \N was a holdover from the tutorial I was reading, which meant to match any single character when I alrady had .* doing everything in between. Also, (.*) is greedier, which is good to use when there is no chance of spillover into another part of the string. I will update my program and save some cycles 😇.

Link to comment
Share on other sites

I really want to solve this.
I want to get the name of both exe files.

jre-8u201-windows-i586.exe
jre-8u201-windows-x64.exe

jre-(?:\d+-u\d+)-windows-|.*(?:[i])\d+\.exe ;x86
jre-(?:\d+-u\d+)-windows-|.*(?:[x64])\d+\.exe ;x64
#include <file.au3>

$pathjava = @ScriptDir
$Fileversionjava = "jre-*.exe"
$Searchjava = _FileListToArrayRec($pathjava, $Fileversionjava)
If IsArray($Searchjava) Then
    _ArrayDisplay($Searchjava)
    For $j = 0 To UBound($Searchjava) - 1
        If @OSArch = "X86" Then
            $RegExpjavax86 = StringRegExp($Searchjava[$j], 'jre-(?:\d+-u\d+)-windows-|.*(?:[i])\d+\.exe', 3)
            If IsArray($RegExpjavax86) Then
                ConsoleWrite($RegExpjavax86[0] & @CRLF)
                ;ShellExecuteWait(@ScriptDir & "\" & $RegExpjavax86[0], "/s")
            EndIf
        Else
            $RegExpjavax64 = StringRegExp($Searchjava[$j], 'jre-(?:\d+-u\d+)-windows-|.*(?:[x64])\d+\.exe', 3)
            If IsArray($RegExpjavax64) Then
                ConsoleWrite($RegExpjavax64[0] & @CRLF)
                ;ShellExecuteWait(@ScriptDir & "\" & $RegExpjavax64[0], "/s")
            EndIf
        EndIf
    Next
EndIf

 

Edited by youtuber
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...