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...
?
Using index() + loop to extract string between two substrings. In this, we get the indices of both the substrings using index(), then a loop is used to iterate within the index to find the required string between them.
Extracting text between characters in Excel 365 In Excel 365, you can get text between characters more easily by using the TEXTBEFORE and TEXTAFTER functions together. This formula also works nicely for extracting text between two occurrences of the same character.
To extract the text between any characters, use a formula with the MID and FIND functions. The FIND Function locates the parenthesis and the MID Function returns the characters in between them.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With