StrLib: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
(Created page with "== Description == A string library LogicLib string-test operators and string transformation macros. == Minimum Requirements == * NSIS 3.0 (Unicode) * Windows 2000 / Windows Vista for the <code>${Slugify}</code> macro == Logical Operators == LogicLib extensions for string prefix, suffix and substring tests. Usage: All standard LogicLib flow operators work automatically: <code>If</code>, <code>IfNot</code>, <code>Unless</code>, <code>ElseIf</code>, <code>ElseIfNot</c...") |
No edit summary |
||
| Line 10: | Line 10: | ||
== Logical Operators == | == Logical Operators == | ||
LogicLib extensions for string prefix, suffix and substring tests. | LogicLib extensions for string prefix, suffix and substring tests. | ||
All standard LogicLib flow operators work automatically: | All standard LogicLib flow operators work automatically: | ||
Revision as of 22:58, 27 February 2026
Description
A string library LogicLib string-test operators and string transformation macros.
Minimum Requirements
- NSIS 3.0 (Unicode)
- Windows 2000 / Windows Vista for the
${Slugify}macro
Logical Operators
LogicLib extensions for string prefix, suffix and substring tests.
All standard LogicLib flow operators work automatically:
If, IfNot, Unless, ElseIf, ElseIfNot, ElseUnless, AndIf, AndIfNot, OrIf, OrIfNot, etc.
Case-insensitive tests:
${If} $Haystack ${StartsWith} $Needle
DetailPrint "Haystack starts with Needle"
${EndIf}
${IfNot} $FileName ${EndsWith} ".tmp"
DetailPrint "Not a temp file"
${EndIf}
${If} $Path ${Contains} "temp"
DetailPrint "Path contains temp"
${ElseIf} $Path ${Contains} "cache"
DetailPrint "Path contains cache"
${EndIf}
Case-sensitive tests (S suffix, like StrCmpS):
${If} $Haystack ${StartsWithS} "HTTP"
${If} $FileName ${EndsWithS} ".DLL"
${If} $Path ${ContainsS} "Temp"
Transformations
String transformation macros
${Trim} " hello " $R0 ; "hello"
${TrimLeft} " hello " $R0 ; "hello "
${TrimRight} " hello " $R0 ; " hello"
${PadLeft} "hi" 5 "0" $R0 ; "000hi"
${PadRight} "hi" 5 "." $R0 ; "hi..."
${Reverse} "Hello" $R0 ; "olleH"
${ToLowerCase} "Hello World" $R0 ; "hello world"
${ToUpperCase} "Hello World" $R0 ; "HELLO WORLD"
${ToPascalCase} "hello_world" $R0 ; "HelloWorld"
${ToCamelCase} "hello_world" $R0 ; "helloWorld"
${ToSnakeCase} "helloWorld" $R0 ; "hello_world"
${ToConstantCase} "helloWorld" $R0 ; "HELLO_WORLD"
${ToCapitalCase} "hello_world" $R0 ; "Hello World"
${ToKebabCase} "helloWorld" $R0 ; "hello-world"
${Slugify} "Ärger über Öl" $R0 ; "arger-uber-ol"
All transforms support Unicode Latin characters (ö, é, ø, etc.). Slugify transliterates accented characters to ASCII equivalents.