Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
ngosz4074
Contributor III
Contributor III

using rtrim to isolate server name

I have a server path (or paths) that we want to do selections on the server name only. 

Example:  \\server1\Folder Path

var1 - mid(Path, index(Path,'\\', 1) + 2) to remove the first two slashes

var2 - RTrim(Path) - ??

What's the best way to accomplish removing everything after the slash after server1 and be flexible to handle different string lengths?

Thanks in advance

5 Replies
ramoncova06
Partner - Specialist III
Partner - Specialist III

you can use subfield


subfield(mid(Path, index(Path,'\\', 1) + 2) ,'\',1)


you can use subfield for the whole thing subfield(Path,'\',3) if you do not want to use the mid function

petter
Partner - Champion III
Partner - Champion III

You can pick out the part of the path you want by using SubField()-function. This can be used both in a load script but also in the running application in the UI.

SubField( Path , '\' , 3 ) will pick out the server1

Since the first element is empty... the string starts with a backslash. The second part is empty - since there is nothing between the two first backslashes.

You can also index backwards by using a negative index. So SubField( Path , '\' , -1 ) will give you the text after the last backslash.

maxgro
MVP
MVP

for server1

= subfield(replace('\\server1\Folder Path', '\\', ''), '\', 1)

sasiparupudi1
Master III
Master III

folder path

trim(subfield(Replace( '\\server1\Folder Path','\\',''),'\',2))

server name

subfield(Replace( '\\server1\Folder Path','\\',''),'\',1)

hth

Sasi

swuehl
MVP
MVP

Or using Textbetween()

=TextBetween('\\server1\Folder','\\','\')

=TextBetween(path ,'\\','\')