java - Need to get string part between two / in a string -


i new java need main string have eg. "string1/string2/string3/string4/all_free.sdx" "file1/file2/string3/string4/all_free.sdx"

the end result need able isolate , string3 can indexof not able achieve in few steps need brainy people new java

if know it's third item want get, 1 simple approach using split method, this:

string mystring = "string1/string2/string3/string4/all_free.sdx"; string string3 = mystring.split("/")[2]; 

the call of split("/") produces array of strings this:

{"string1", "string2", "string3", "string4", "all_free.sdx"} 

now can apply subscript operator grab element want.


Comments