HeXetic Posted August 13, 2009 Share Posted August 13, 2009 I'm trying to format a string using StringFormat but i'm not sure how to do it properly. The string I'm formatting is this: \\Servername\HP Laser Color 3500 What I want to end up with is the "Servername" as one string and "HP Laser Color 3500" as another string. Of course if there is a better way of doing this instead of using StringFormat let me know. Link to comment Share on other sites More sharing options...
colafrysen Posted August 13, 2009 Share Posted August 13, 2009 Dirty method, but whatever... $aSplits = StringSplit ( "\\Servername\HP Laser Color 3500", "\") $Server = $aSplits[$aSplits[0]-1] $Printer = $aSplits[$aSplits[0]-0] ConsoleWrite($Server & @CRLF) ConsoleWrite($Printer & @CRLF) [font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size] Link to comment Share on other sites More sharing options...
Scriptonize Posted August 13, 2009 Share Posted August 13, 2009 (edited) Also possible: #include<array.au3> $text = "\\Servername\HP Laser Color 3500" $text = StringReplace($text,"\\","\") $array = StringSplit($text,'\',2) _ArrayDisplay($array) ;So the values you are looking for are in $array[1] and $array[2] Edited August 13, 2009 by Scriptonize If you learn from It, it's not a mistake Link to comment Share on other sites More sharing options...
HeXetic Posted August 13, 2009 Author Share Posted August 13, 2009 Also possible: #include<array.au3> $text = "\\Servername\HP Laser Color 3500" $text = StringReplace($text,"\\","\") $array = StringSplit($text,'\',2) _ArrayDisplay($array) ;So the values you are looking for are in $array[1] and $array[2] This works great, thanks a lot man. It looks like StringSplit was the function I need, I don't know how I missed that. Link to comment Share on other sites More sharing options...
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