String question

i have this string:
try_dir=“program files/tbla/bla1”

how can i slice it in string1=program files" string2=“tbla”
string3=“bla1”

tnx

Bulhac M. wrote:

i have this string:
try_dir=“program files/tbla/bla1”

how can i slice it in string1=program files" string2=“tbla”
string3=“bla1”

try_dir = “program files/tbla/bla1”
=> “program files/tbla/bla1”

string1, string2, string3 = try_dir.split(’/’)
=> [“program files”, “tbla”, “bla1”]

string1
=> “program files”

string2
=> “tbla”

string3
=> “bla1”

String#split

HTH

Regards,
Lee

Bulhac M. wrote:

i have this string:
try_dir=“program files/tbla/bla1”

how can i slice it in string1=program files" string2=“tbla”
string3=“bla1”

ar = Array.new
ar = “program files/tbla/bla1”.split("/")
p ar

=> [“program files”, “tbla”, “bla1”]

Lloyd L. wrote:

ar = Array.new
ar = “program files/tbla/bla1”.split("/")

The array created by Array.new will be replaced by the array created by
split
in the very next line and thus never be used. In other words: you can
leave
the first line out.