So I'm trying to extract the strings between the / delimiters of the url. This has proven to be a bit hard for me as Java does not accept "/" as a char.
String temp = "svn+ssh://xxxxxx.net/var/lib/webprojects/xxx/xxx/WebContent/images/Calendar_icon.png";
How could I get, from this String : images , WebContent , etc...
?
How about splitting the string by /
-
String[] parts = temp.split("/");
and accessing the relevant parts by their index positions.
First, use a regex to remove what you don't want:
String temp = temp.replaceAll("^.*//xxxxxx.net","");
Then split it:
String[] parts = temp.split("/");
You should use split function. With this, you will have your String
divide in an array of Strings by the positions of where "/" it's placed. So, for example, if you want to access to the url, in your case will be:
String split[] = temp.split("/"); //Here you have your String divide.
So, to access to the url (look that it is on the second position of the array (because in the first position it's svn+ssh:
) you will have to do:
split[1];
I expect it will be helpful for you!
尝试使用string的split函数
String[] stringArray = temp.split("/");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.