Archive: Character Find and Replace Help


Character Find and Replace Help
Hello all.

I need a little help with a string edit. At the end of my installer, I will have a variable called $modules. It contains a string with an unknown amount of words, separated by commas. Like this:

"Loans, Deposits, Mortgage"

What I would like is to edit the string contained in $modules to replace the only the last comma with " and". So I would end up with:

"Loans, Deposits and Mortgage"

I have checked out NSIS Wiki for a function to do this, but could not find one. My best thought so far was to use StrLoc to identify the index number of the last comma, but I could not then find a function that allows me to do a find and replace within a string by index number.

Any ideas? Thanks guys.



Name "Output"
OutFile "Output.exe"

!include "WordFunc.nsh"
!insertmacro WordReplace


Section
${WordReplace} "Loans, Deposits, Mortgage" "," " and" "-1" $0

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

Thanks Instructor, that worked like a charm!