gpt4 book ai didi

nsis - 如何在 NSIS 中拆分字符串

转载 作者:行者123 更新时间:2023-12-05 01:34:32 26 4
gpt4 key购买 nike

字符串 "jdbc:postgresql://localhost:5432/DatabaseName"

我的要求是只获得 数据库名称 从上面的字符串。

我试过下面的链接,但没有用。

${Explode} $0 "jdbc:postgresql://localhost:5432/" "$v1" 

它给出错误无效命令。

http://nsis.sourceforge.net/Explode

NSIS 语言是如何实现的。因为我不太熟悉 NSIS 语言。
请做必要的帮助。提前致谢。

最佳答案

如果您只需要在最后一个 / 之后获取字符串的其余部分你可以只使用一些基本的 NSIS 字符串处理:

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

关于nsis - 如何在 NSIS 中拆分字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27164243/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com