editing strings

Doubts, help and support about QuickBMS and other game research tools
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

editing strings

Post by spider91 »

I have NAMEs like "0123ABCD_1", "4567EFAB_2", etc. How can i write last 2 simbols ("_1", "_2" and so on) to another variable, then remove it from NAME to finally get two separate parts. For example if i have NAME = "4567EFAB_5" it should transform to NAME = "4567EFAB" and INDEX = "_5"
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: editing strings

Post by aluigi »

There are various solutions, in your specific case I would adopt the following:

Code: Select all

set NAME string "4567EFAB_2"
string NAME s "%x_%d" VAR1 VAR2
print "%VAR1%"
print "%VAR2%"

Please note that the 's' operator of the String command works only with numbers so you cannot use %s
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: editing strings

Post by spider91 »

Thanks, and what is the solution if name looks like this "V81BobbyPreDisease07_7", simple names (not hex numbers) at the beginning and index at the end?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: editing strings

Post by aluigi »

Code: Select all

set NAME string "4567EFAB_2"
set VAR1 string NAME
set VAR2 string NAME
string VAR1 > "_"
string VAR2 ! "_"
print "%VAR1%"
print "%VAR2%"
spider91
Posts: 233
Joined: Sun Aug 24, 2014 5:26 pm

Re: editing strings

Post by spider91 »

Perfect, thanks a lot.