Jump to content

StringRegExp Design GUI


w0uter
 Share

Recommended Posts

[edit] JON you should really fix the code-tag it looks so sloppy. im a bad coder ;) [/edit]

this app was designd to easy test regexp patterns on the fly.

in like ~4 hours, since i ran into that regexp bug.

thought i got all the bugs out but if you find one let me know.

#include <GuiConstants.au3>

GUICreate("StringRegExp Design GUI -by w0uter", 550, 500, (@DesktopWidth - 550) / 2, (@DesktopHeight - 500) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

GUICtrlCreateGroup("The text to check", 10, 10, 530, 130)
GUICtrlCreateGroup("The pattern", 10, 150, 530, 50)
GUICtrlCreateGroup("Output", 140, 210, 400, 280)
GUICtrlCreateGroup("Return", 10, 210, 120, 100)
GUICtrlCreateGroup("@Error", 10, 320, 120, 50)
GUICtrlCreateGroup("@Extended", 10, 380, 120, 50)

$h_Radio_0 = GUICtrlCreateRadio("True/False", 20, 230, 100, 20)
$h_Radio_1 = GUICtrlCreateRadio("Array with the text", 20, 251, 100, 27)
$h_Radio_3 = GUICtrlCreateRadio("Array of all results", 20, 280, 100, 20)
GUICtrlSetState($h_Radio_3, $GUI_CHECKED)

$h_In = GUICtrlCreateEdit("", 20, 30, 510, 100)
$h_Out = GUICtrlCreateList("", 150, 226, 380, 262)

$h_Pattern = GUICtrlCreateInput("(.*)", 20, 170, 510, 20)
$h_Err = GUICtrlCreateInput("0", 20, 340, 100, 20, $ES_READONLY)
$h_Ext = GUICtrlCreateInput("bla", 20, 400, 100, 20, $ES_READONLY)

$h_Exit = GUICtrlCreateButton("Exit", 10, 440, 120, 50)

$v_Reg_Old = 0

GUISetState()

While 1
    
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $h_Exit
            ExitLoop
    EndSwitch
    
    _Valid()
    
WEnd


Func _Valid()
    
    $v_Reg = StringRegExp(GUICtrlRead($h_In), GUICtrlRead($h_Pattern), _Option())
    
    Dim $v_EE[2] = [@error, @extended]
    
    If $v_EE[0] = 2 Then
        GUICtrlSetColor($h_Pattern, 0xFF0000)
        GUICtrlSetData($h_Err, $v_EE[0])
        GUICtrlSetData($h_Out, "")
    Else
        GUICtrlSetColor($h_Pattern, 0)
        GUICtrlSetData($h_Err, $v_EE[0])
    EndIf
    
    GUICtrlSetData($h_Ext, $v_EE[1])
    
    If $v_EE[0] <> 2 Then
        $v_Check = 0
        If UBound($v_Reg) <> UBound($v_Reg_Old) Then
            $v_Check = 1
        Else
            For $i = 0 To UBound($v_Reg) - 1
                If $v_Reg[$i] <> $v_Reg_Old[$i] Then $v_Check = 1
            Next
        EndIf
        
        If $v_Check = 1 Then
            
            GUICtrlSetData($h_Out, "")
            
            If UBound($v_Reg) Then
                
                For $i = 0 To UBound($v_Reg) - 1
                    GUICtrlSetData($h_Out, $i & ' = ' & $v_Reg[$i])
                Next
            Else
                GUICtrlSetData($h_Out, $v_Reg)
            EndIf
        EndIf
    EndIf
    
    $v_Reg_Old = $v_Reg
    
    StringRegExp('', Random(0x80000000, 0x7FFFFFFF), 1)
    
EndFunc  ;==>_Valid


Func _Option()
    Switch $GUI_CHECKED
        Case GUICtrlRead($h_Radio_0)
            Return 0
        Case GUICtrlRead($h_Radio_1)
            Return 1
        Case GUICtrlRead($h_Radio_3)
            Return 3
    EndSwitch
EndFunc  ;==>_Option
Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

i think it is ;)

since you dont have an Group.

( ... ) Group.

The elements in the group are treated in order and can be repeated together. e.g. (ab)+ will match "ab" or "abab", but not "aba". A group will also store the text matched for use in back-references and in the array returned by the function, depending on flag value.

try "ceci est un test" with this pattern "(est)".

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

i think it is ;)

since you dont have an Group.

try "ceci est un test" with this pattern "(est)".

does a group is always needed? if yes why not to add a clear error message explaining the @error/@extended values

You know I am not an expert in regexp. :P

Link to comment
Share on other sites

how about

red = invalid pattern

orange = needs a group

black = correct pattern

and make

@error 0/2 -> Error: None / Invalid pattern (and maby / No Group)

@extended 0/1 -> Matched: Yes / No

btw thanx for showing interest ;)

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

how about

red = invalid pattern

orange = needs a group

black = correct pattern

and make

@error 0/2 -> Error: None / Invalid pattern (and maby / No Group)

@extended 0/1 -> Matched: Yes / No

btw thanx for showing interest ;)

Why to use only color?

just update a label with color if you want to display the error

Link to comment
Share on other sites

hmm, im lost in my own code due to all those spagetti work-arounds for that StringRegExp bug.

ive decided to give up this project till they will fix the bug.

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

hmm, im lost in my own code due to all those spagetti work-arounds for that StringRegExp bug.

ive decided to give up this project till they will fix the bug.

Be sure to post it in the proper Bug report forum. I see that your linked post is in the Support forum, I think it makes a difference. ;)

Thanks for working on this function by the way. Most of the community doesn't seem to post much. I know how it is working on stuff and then getting annoyed by the apparent lack of intrest. It is indeed sad when the most viewed thread is drama related or about girls, but what can you do. :P

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