EndFunc Posted November 25, 2009 Posted November 25, 2009 (edited) 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 November 25, 2009 by EndFunc EndFuncAutoIt is the shiznit. I love it.
Authenticity Posted November 25, 2009 Posted November 25, 2009 If StringRight($Path, 1) = "\" Then $Path = StringTrimRight($Path, 1)
Moderators SmOke_N Posted November 25, 2009 Moderators Posted November 25, 2009 Or just one function call: $Path = StringRegExpReplace($Path, "\\+\z", "") Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
EndFunc Posted November 25, 2009 Author Posted November 25, 2009 If StringRight($Path, 1) = "\" Then $Path = StringTrimRight($Path, 1) Seriously? LOL told you it was easy. I was close. I guess I really need a better understanding of how some of these string commands work. Thanks for quick response. EndFuncAutoIt is the shiznit. I love it.
EndFunc Posted November 25, 2009 Author Posted November 25, 2009 (edited) Or just one function call: $Path = StringRegExpReplace($Path, "\\+\z", "") I would never get this on my own. I am fairly decent using the String commands but Regular expression is just even more greek. I leave with a headache. lol Thanks again. Edited November 25, 2009 by EndFunc EndFuncAutoIt is the shiznit. I love it.
PsaltyDS Posted November 25, 2009 Posted November 25, 2009 ...but Regular expression is just even more geek.Corrected your spelling. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now