I have the following string.
http://localhost:8080/test/tf/junk?tx=abc&xy=12345
Now I want to get substring between the third and fourth slash "/
" using javascript.
To be more clear, I want to extract test
from the above given string.
Can anybody help me out on this?
答案 0 :(得分:2)
You can split your string into an array
var str = "http://localhost:8080/test/tf/junk?tx=abc&xy=12345";
str = str.replace("http://", "");
var array = str.split("/");
for(var i = 0; i < array.length; i++) {
alert(array[i]);
}