Archive: Trimming spaces


Trimming spaces
Ok, before I reinvent the wheel, has someone written some code to trim spaces on both sides of a string?

' xyz abc ' -> 'xyz abc'


Thanks,
Thierry


Name "Output"
OutFile "Output.exe"

!include "WordFunc.nsh"
!insertmacro WordReplace

Section
${WordReplace} " xyz abc " " " "" "{}" $R0
# $R0="xyz abc"

MessageBox MB_OK '$$0={$0}'
SectionEnd

Or, use this function. It will trim all leading and trailing whitespaces (including tabs, CR and LF).
Usage:


Push ' xyz abc '
Call Trim
Pop $0 ;$0 now contains the trimmed string.