Jump to content

StringRegExp Help


 Share

Go to solution Solved by Tormiasz,

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

Tormiasz,

Please post the code that does not work. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

    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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...