Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSIS substring by index

Is there any function which can cut string by letter index? I mean the X letters from the end?

!define myString "abcdefg"

I need to get for ex. "efg"

i tried to do that with nsis strings functions but didnt found what can help me. ${StrStr} and all the other functions doesnt do the work

Thanks

like image 547
user2269104 Avatar asked Aug 08 '13 15:08

user2269104


2 Answers

This is very simple. Actually, you don't have any dedicated function to do that, but you StrCpy can do that with 3rd and 4th arguments.

The format is going like that:

user_var(destination) str [maxlen] [start_offset]

And the usage for you case, is:

StrCpy $0 $myString "" -3

$0 will be: efg

More information about StrCpy function, can be found out there: http://nsis.sourceforge.net/Reference/StrCpy

like image 122
Idan Gozlan Avatar answered Oct 21 '22 11:10

Idan Gozlan


StrCpy $0 "abcdefg" "" -3 ; variable $0 now has the last 3 letters

See the manual for more info about StrCpy

like image 2
Anders Avatar answered Oct 21 '22 11:10

Anders