I have a String for example this String:
bigString = "<div dir=\"rtl\" style=\"text-align: right\"><ul><li><span>רשאי, רק כאשר הרכב העוקף הוא רכב משא.</span></li><li><span>רשאי, רק בדרך שאינה עירונית.</span></li><li><span id=\"correctAnswer1759\">רשאי.</span></li><li><span>רשאי, אם באוטובוס אין נוסעים.</span></li></ul><div style=\"padding-top: 4px;\"><span><button type=\"button\" onclick=\"var correctAnswer=document.getElementById('correctAnswer1759');correctAnswer.style.background='yellow'\">הצג תשובה נכונה</button></span><br/><span style=\"float: left;\">| «D» | </span></div></div>"
I want to get each one of those Strings.
For that I decided to save in array the first String between <li><span>HERE</span></li>
and then remove the tags that was covering it from the big String and to do it 3 times until each one of those Strings are in array.
I could do it with Java but there is another problem with Java so I decided to do it in JavaScript.
In Java I could use this function to get the first String:
arr[j] = StringUtils.substringBetween(bigString,"<li><span>","</span></li>");
And then replace the first <li><span> </span></li> tags with those functions:
bigString = bigString.replaceFirst("<li><span>","<null>");
bigString = bigString.replaceFirst("</span></li>","<null>");
Now I can't find proper functions to replace the Java ones.
var bigString = data.records[0].description4;
var end = "</span></li>";
var start = "<li><span>";
var strings = []; bigString.split(end).forEach(s => {index = s.indexOf(start);
if (index >= 0) {strings.push(s.substring(index + 3)); }});
for(var i = 0; i < 3; i++){
console.log(strings[i]);
}
Result: https://prnt.sc/w1wugv
The result I need: רשאי, רק כאשר הרכב העוקף הוא רכב משא. רשאי, רק בדרך שאינה עירונית. רשאי, אם באוטובוס אין נוסעים.