|
|
#1 |
|
Member
Join Date: Jan 2006
Location: USA
Posts: 82
|
How to remove trailing slash
How would one remove a trailing \ from a variable's last position? If this was C++, I'd just check if the last character was a \ and remove it...
I tried using WordReplace: code: The problem I'm running into, is that if a variable holds just C:\, then it works fine (spits out C:). If the variable holds C:\Inetpub\wwwroot, it'll spit out C:\Inetpubwwwroot. |
|
|
|
|
|
#2 |
|
Major Dude
Join Date: Jul 2004
Posts: 665
|
code: |
|
|
|
|
|
#3 |
|
Member
Join Date: Jan 2006
Location: USA
Posts: 82
|
That seems to work great. Knew I must've been missing something simple...
|
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Dec 2005
Location: Glow
Posts: 285
|
${WordReplace} is pretty heavy solution for this problem. This simple code will do the same thing.
; $R0 = your path StrCpy $R1 "$R0" "" -1 ; this gets the last char StrCmp $R1 "\" 0 +2 ; check if last char is '\' StrCpy $R0 "$R0" -1 ; last char was '\', remove it |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|