Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
Extract String in Java
I want to extract only certain portion of String followed by = sign The string is ā[AlbumId=1, CategoryId=1, albumTitle=DJ NYK, hirePrice=20, noofCD=5, status=Available]ā From here I want to extract "1","1","DJ NYK","20",5,"Available" .I have tried with split() but I cannot extract properly .Will be highly grateful if I receive any help
2 Respostas
+ 4
notstacked
You can first split string on comma (,) then after splitting string will be convert in array of string.
Now use for loop and split each string of that new array with equal (=)
Here is an example:
String str = "1=2, 3=4, 5=6";
String [] arr = str.split(", ");
for (String s : arr) {
String[] a = s.split("=");
System.out.println(a[1]);
}
+ 1
Thank you so much AĶ¢J