Ho un'area di testo che devo analizzare. Ogni nuova linea deve essere estratta e su di essa deve essere eseguita un'operazione. Al termine dell'operazione, l'operazione deve essere eseguita sulla riga successiva. Questo è quello che ho al momento. So che la ricerca indexOf non funzionerà perché cerca caratteri per carattere.analizza un'area di testo in sottostringhe in base alle interruzioni di riga in Javascript
function convertLines()
{
trueinput = document.getElementById(8).value; //get users input
length = trueinput.length; //getting the length of the user input
newinput=trueinput; //I know this looks silly but I'm using all of this later
userinput=newinput;
multiplelines=false; //this is a check to see if I should use the if statement later
for (var i = 0; i < length; i++) //loop threw each char in user input
{
teste=newinput.charAt(i); //gets the char at position i
if (teste.indexOf("<br />") != -1) //checks if the char is the same
{
//line break is found parse it out and run operation on it
userinput = newinput.substring(0,i+1);
submitinput(userinput);
newinput=newinput.substring(i+1);
multiplelines=true;
}
}
if (multiplelines==false)
submitinput(userinput);
}
Quindi per la maggior parte sta prendendo il userinput. Se ha moltiplicato le linee, eseguirà ogni riga e separatamente ed eseguirà submitinput. Se voi ragazzi potete aiutarmi, sarei eternamente grato. Se avete domande non esitate a chiedere