NSIS substring by index
Asked Answered
H

2

6

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

Harkins answered 8/8, 2013 at 15:54 Comment(0)
A
12

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

Appearance answered 9/8, 2013 at 8:10 Comment(0)
B
2
StrCpy $0 "abcdefg" "" -3 ; variable $0 now has the last 3 letters

See the manual for more info about StrCpy

Beautify answered 9/8, 2013 at 4:22 Comment(1)
if i have a path like this "C:\Users\PK\AppData\Local\Programs\Microsoft VS Code\bin\code C:\Users\PK\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd" how do i get the output as "C:\Users\PK\AppData\Local\Programs\Microsoft VS Code\bin"Julius

© 2022 - 2024 — McMap. All rights reserved.