Jump to content

StringRegExp Help


Go to solution Solved by Tormiasz,

Recommended Posts

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
  • Moderators
Posted

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:

  Reveal hidden contents

 

  • Solution
Posted (edited)

I found my bad...

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

Edited by Tormiasz
  • Moderators
Posted

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:

  Reveal hidden contents

 

  • Moderators
Posted

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:

  Reveal hidden contents

 

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
  • Moderators
Posted

Tormiasz,

 

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

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:

  Reveal hidden contents

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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