我有一个需要解析的文本区域。每条新生产线都需要拔出,并且需要对其进行操作。操作完成后,需要在下一行运行该操作。这是我目前所拥有的。我知道indexOf搜索将无法正常工作,因为它正在逐字搜索。根据Javascript中的换行符来解析子字符串中的textarea
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);
}
因此,大多数情况下它采用userinput。如果它有多条线,它将运行投掷每条线并分别运行submitinput。如果你们能帮助我,我会永远感激。如果您有任何疑问,请向