Sign in to follow this  
Followers 0
Valuater

StringRegExpress....?

8 posts in this topic

I am reading the Registry and this just looks messy... any thoughts??????

Global $tCount

; This works
 _RegHandler( 1, "HKCU", "C:\Program Files\Autoitv3\Examples\Test.txt")
 
 ; This does not work - a folder
 _RegHandler( 3, "HKCU", @ProgramFilesDir & "\Autoitv3test\") ; with and without the last "\"

;Some look like these
; "C:\Program Files\Autoitv3\Examples\Test.txt",1
; "C:\Program Files\Autoitv3\Examples\Test.txt"|23.. or letters
; I guess i dont need these



Func _RegHandler($iLevel, $iKey, $iReg)
    
    If StringInStr($iReg, @HomeDrive) And StringLeft($iReg, 1) = StringLeft(@HomeDrive, 1) And Not FileExists($iReg) Then
        ; GUICtrlSetData($STATUS, $iReg); I use this
        
        ;If Not StringInStr($iReg, @CR) And Not StringInStr($iReg, "system32") Then
            ;MsgBox(0,0,StringLen(StringTrimLeft($iReg, StringInStr($iReg, "."))))
            If StringLen(StringTrimLeft($iReg, StringInStr($iReg, "."))) == 3 Then
                $iReg = FileGetLongName($iReg); doesnt work because it not exist
                $tCount += 1
                
                MsgBox(4096, $iLevel & "-" & $tCount, $iKey & "         " & @CRLF & $iReg, 25)
            EndIf
        ;EndIf
        
        If StringInStr(FileGetAttrib($iReg), "D") Then ; doesnt work because it not exist
            $tCount += 1
            
            MsgBox(4096, $iLevel & "-" & $tCount, $iKey & "         " & @CRLF & $iReg, 25)
        EndIf
    EndIf
EndFunc   ;==>_RegHandler

thx

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites



Found it difficult to understand what you actually wanted.

StringRegExpReplace($s_str, "(?i)(.*?)([a-z]:(?:.*?\\)+(.*?\.\w+)*)", "\2")
?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Found it difficult to understand what you actually wanted.

StringRegExpReplace($s_str, "(?i)(.*?)([a-z]:(?:.*?\\)+(.*?\.\w+)*)", "\2")
?

How can I explain when I don't even know... :)

I'm just a bit tired, but

I just narrowed down what i had and will be posting the whole prog soon

Thanks Ron

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

How can I explain when I don't even know... :)

I'm just a bit tired, but

I just narrowed down what i had and will be posting the whole prog soon

Thanks Ron

8)

From your comments (in the code), and what I could make out the others, it looked like you were trying to narrow down the file from the registry return string... my other expression was wrong, this may even need some work... but it looked like it did what you would need to verify:
$s_str = '"C:\Program Files\Autoitv3\Examples\Test.txt",1'
$s_strip = StringRegExpReplace($s_str, "(?i)(.*?)([a-z]:(?:.*?\\)+(.*?\.\w+)*)(.*?)*\z", "\2")
ConsoleWrite($s_str & @CRLF & "Becomes..." & @CRLF & $s_strip & @CRLF)
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

From your comments (in the code), and what I could make out the others, it looked like you were trying to narrow down the file from the registry return string... my other expression was wrong, this may even need some work... but it looked like it did what you would need to verify:

$s_str = '"C:\Program Files\Autoitv3\Examples\Test.txt",1'
 $s_strip = StringRegExpReplace($s_str, "(?i)(.*?)([a-z]:(?:.*?\\)+(.*?\.\w+)*)(.*?)*\z", "\2")
 ConsoleWrite($s_str & @CRLF & "Becomes..." & @CRLF & $s_strip & @CRLF)
That might help, I will have to check it out.

thanks..!!

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

That cleared more than 95% of the problem files... :)

I do have one ( on my computer) that ends up like this

C:\Program Files\Autoitv3\Examples\"Test.txt

I know I could string() fix, but if you can add that it would be great

My biggest concern is "other" users, because it's just a scanner right now

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

That cleared more than 95% of the problem files... :)

I do have one ( on my computer) that ends up like this

C:\Program Files\Autoitv3\Examples\"Test.txt

I know I could string() fix, but if you can add that it would be great

My biggest concern is "other" users, because it's just a scanner right now

8)

You should probably just wrap it in another expression to remove non-standard file characters.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks for the help... appreciated :)

8)


NEWHeader1.png

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  
Followers 0