Jump to content

StringinStr an d StringRight..


EndFunc
 Share

Recommended Posts

Ok I've been trying to trim a UNC path and getting stumped. Sometimes I can get the hardest things and the things I think should be easy, I get stumped. LOL

Well say I have a unc path

\\pathtomyscript\users\

I want to take off the last \ on that string.

That was easy enough using stringinstr but then, it would still count any \ it finds and trims the last letter. I only want it to trim the last slash if its there if its not the last character in the string then do nothing.

I tried

$Path = "\\pathtomyscript\users\"
If StringinStr($Path, "\", "2", "-1", "1", "1") Then
$tPath = StringTrimRight($Path, "1")
End

So the result I want to be \\pathtomyscript\users but only if the string had a \ on the end to begin with.

But that only works if the \ is on the end. If it's not it removes the s in users. I can't figure out how to not process this if there is a \ on the end only.

Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...