Sign in to follow this  
Followers 0
Tormiasz

StringRegExp Help

9 posts in this topic

#1 ·  Posted (edited)

Hello, I have this code:

Local $aSearcher = 'gGuestServer = "None",'
Local $aSearchString = 'gGuestServer = "(.*?)",'
Local $aSavedGuestServer = StringRegExp($aSearcher, $aSearchString, 3)

And it works well, finding the "None".

But when $aSearcher will have several lines (from FileRead()), it can't find anything. I am sure there is this text, checked by ClipPut. What I am doing wrong?

Tried also '(?m)gGuestServer = "(.*?)(?m)'

Thanks for answers.

Edited by Tormiasz

Share this post


Link to post
Share on other sites



Tormiasz,

This seems to work: :)

#include <Array.au3>
Local $aSearcher = 'gGuestServer = "None"' & @CRLF & _
                    'gGuestServer = "Tom"' & @CRLF & _
                    'gGuestServer = "Dick"' & @CRLF & _
                    'gGuestServer = "Harry"'

Local $aSearchString = 'gGuestServer\s=\s\x22(.*)\x22'
Local $aSavedGuestServer = StringRegExp($aSearcher, $aSearchString, 3)
_ArrayDisplay($aSavedGuestServer)

; And you can make the search pattern much simpler
Local $aSearchString = '\x22(.*)\x22'
Local $aSavedGuestServer = StringRegExp($aSearcher, $aSearchString, 3)
_ArrayDisplay($aSavedGuestServer)
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I found my bad...

Used Same name for variable and a argument, it's forbidden with stringregexp.

Edited by Tormiasz

Share this post


Link to post
Share on other sites

question for melba,

why did you use the hex22 to represent the " ?

Share this post


Link to post
Share on other sites

gruntydatsun,

Because I use the double quote as a string delimiter when I code - so I cannot use it inside a RegEx pattern. Just force of habit really. :)

And before you mention that I did not do this in the code above - that was a straight copy-paste from the OP. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Ehh.. It's still not working after the change. IDK what is causing the problem.

Share this post


Link to post
Share on other sites

Tormiasz,

Please post the code that does not work. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

    Local $aAccountName1 = _Crypt_HashData($accounts[$aBotNumber - 1][0], $CALG_MD5)
    Local $aAccountName = StringLower(StringTrimLeft($aAccountName1, 2)) & "_settings.lua"
    Local $aWriteToMinion = @ScriptDir & "\LuaMods\gw2minion\" & $aAccountName

    Local $aSearcher = FileRead($aWriteToMinion)
    Local $aSearchString = 'gGuestServer\s=\s\x22(.*)\x22'
    Local $aSavedGuestServer = StringRegExp($aSearcher, $aSearchString, 3)
    Local $aOldGuestServer = IniRead("config.ini", "GUESTSERVER", $aGetParty, "0")

    If $aSavedGuestServer[0] <> $aOldGuestServer Then
        Local $sOldGuestServer = 'gGuestServer = "' & $aSavedGuestServer[0]
        Local $sNewGuestServer = 'gGuestServer = "' & $aOldGuestServer
        _ReplaceStringInFile($aWriteToMinion, $sOldGuestServer, $sNewGuestServer)
    EndIf

$aWriteToMinion is fine, I've checked it.

Edited by Tormiasz

Share this post


Link to post
Share on other sites

Tormiasz,

 

Local $aWriteToMinion = @ScriptDir & "\LuaMods\gw2minion\" & $aAccountName

GW2Minion:

The Best and Safest Guild Wars 2 Bot on the market

So you should not need 3 guesses to know what comes next. ;)

Please read the Forum rules (there is also a link at bottom right of each page) - particularly the bit about not discussing game interaction - before you post again. Then you will understand why you will get no more help and this thread will now be locked. :naughty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0