Sign in to follow this  
Followers 0
momand

Stringsplit And Multiple Delimiters

3 posts in this topic

I'm attempting to use StringSplit on a line such as "z:\\TMG93\techelp\H22562", however I need to be able to split the string after the \\ and the first \. I've tried the command $drives = StringSplit($line, "\\\"), but it splits the string exactly the same as $drives = StringSplit($line, "\\"). Is there any way of specifying multiple delimiters in a case such as this?

Thanks.!

michael.omand@sunlife.com

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

StringSplit supports multiple single-char delimiters, but it does not support multi-char delimiters..... (The help file remarks and example for StringSplit should make some mention of this, but it's easy to overlook)

You would need to first replace the "\\" with a single character such as * or ? or | or any other character guarranteed to not appear in a file name.

$line = StringReplace("z:\\TMG93\techelp\H22562", "\\", "?")
$drives = StringSplit($line, "\?");multiple single-char separators

or you could combine the StringReplace and StringSplit

and I think you could simply replace \\ with \

$drives = StringSplit(StringReplace("z:\\TMG93\techelp\H22562", "\\", "\"), "\")

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

You could do it this way

$I = "z:\\TMG93\techelp\H22562"
$S = StringTrimLeft($I,StringInStr($i,"\\")+1)
$S = StringLeft($S,StringInStr($s,"\")-1)
MsgBox(0,"demo",$s)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0