How to split string in NSIS
nsis
Solution
If all you need is to get the rest of the string after the last `/` you can just use some basic NSIS string handling:
Section
StrCpy $0 "jdbc:postgresql://localhost:5432/DatabaseName"
StrCpy $1 0
loop:
IntOp $1 $1 - 1 ; Character offset, from end of string
StrCpy $2 $0 1 $1 ; Read 1 character into $2, -$1 offset from end
StrCmp $2 '/' found
StrCmp $2 '' stop loop ; No more characters or try again
found:
IntOp $1 $1 + 1 ; Don't include / in extracted string
stop:
StrCpy $2 $0 "" $1 ; We know the length, extract final string part
DetailPrint "|$2|"
SectionEnd
Problem
String "jdbc:postgresql://localhost:5432/DatabaseName" My requirement is to get only the DatabaseName from the above string. I tried below link but it is not worked. ``` ${Explode} $0 "jdbc:postgresql://localhost:5432/" "$v1" ``` It give the error invalid command. http://nsis.sourceforge.net/Explode How it is possible in NSIS language. As i'm not more familiar with NSIS language. Please do the needful help. Thanks in advance.