Reputation: 79
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.
Upvotes: 4
Views: 5333
Reputation: 101666
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
Upvotes: 5
Reputation: 12882
The WordFind function lets you do that, take a look at its examples
Upvotes: 0
Reputation: 2035
You should try the NSISpcre plugin, maybe you need some nasty regex :p
Upvotes: 0