Jump to content

Get filename Regex quotation mark and slash issue


youtuber
 Share

Recommended Posts

Aim at a moving target to make time pass away fast 😉

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

... and patience!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

@mikell 

Your pattern returns two .exe.exe

Testasdf!^+%&()=_ .exe.exe Testblabla!^+%&()=_.exe.exe

 

This is the better working solution for me.

but it won't work if an exe name looks like this Testasdf!^+%&()=_.exe

#include <File.au3>

Local $FileSearch = _FileListToArray(@ScriptDir & "\", "*.exe", 1)
If Not @error Then
    For $i = 1 To $FileSearch[0]
        ;but it won't work if an exe name looks like this Testasdf!^+%&()=_.exe
        $aRegex = StringRegExp($FileSearch[$i], '(?i)([^"]+)(?=.exe)\.\w{2,3}', 3)
        If IsArray($aRegex) Then
            _ChangeEXEnameINau3($aRegex[0])
        EndIf
    Next
EndIf

Func _ChangeEXEnameINau3($aFileNameExe)
    Local $aFileList = _FileListToArray(@ScriptDir & "\MyprojectAu3\", "*.au3", 1)
    If Not @error Then
        For $i = 1 To UBound($aFileList) - 1
            $Au3_path = @ScriptDir & "\MyprojectAu3\" & $aFileList[$i]
            $Read = FileRead($Au3_path)
            $sRegexRep = StringRegExpReplace($Read, '[^"]+(?=\.exe"(?:\h|\)))', $aFileNameExe)
            $Open = FileOpen($Au3_path, 2)
            FileWrite($Open, $sRegexRep)
            FileClose($Open)
        Next
    EndIf
EndFunc   ;==>_ChangeEXEnameINau3

 

Link to comment
Share on other sites

Thank you all

Exactly like I want :)

#include <File.au3>

Local $FileSearch = _FileListToArray(@ScriptDir & "\", "*.exe", 1)
If Not @error Then
    For $i = 1 To $FileSearch[0]
        $aRegexRep1 = StringRegExpReplace($FileSearch[$i], '^.*\\|\.[^.]*$',"")
            _ChangeEXEnameINau3($aRegexRep1)
    Next
EndIf

Func _ChangeEXEnameINau3($aFileNameExe)
    Local $aFileList = _FileListToArray(@ScriptDir & "\MyprojectAu3\", "*.au3", 1)
    If Not @error Then
        For $i = 1 To UBound($aFileList) - 1
            $Au3_path = @ScriptDir & "\MyprojectAu3\" & $aFileList[$i]
            $Read = FileRead($Au3_path)
            $bRegexRep2 = StringRegExpReplace($Read, '[^"]+(?=\.exe"(?:\h|\)))', $aFileNameExe)
            $Open = FileOpen($Au3_path, 2)
            FileWrite($Open, $bRegexRep2)
            FileClose($Open)
        Next
    EndIf
EndFunc   ;==>_ChangeEXEnameINau3

 

 

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...