<meta charset= "Utf-8" ><center><br><br><textarea cols=20 rows= 20 id=suanshu></textarea><input type=button value= "Calculating arithmetic problem" onclick= "Suanshu ()" ></input><textarea cols=20 rows=20 id=jieguo></textarea></center> <script language= "JavaScript" >function suanshu () {var svar ars;var i,l;s= Document.all.suanshu.value; //string.fromcharcode ( ;ars=s.split) ("\x0a"); But webkt only to indicate that the line is wrapped, and IE with #13#10 line, so with the regular to be compatible with different browsers/\r?\n/equivalent to/\r{0,1}\n/. Indicates that \ r appears 0 or 1 times. Ars=s.split (/\r?\n/); l=ars.length;s= ""; for (i=0;i<l;i++) { if (s== "") { s=ars[i]+ "=" +eval (Ars[i]); }else{ s=s+string.fromcharcode (+ars[i]+) "=" +eval (Ars[i]); }} //alert (s); document.all.jiEguo.value=s; }</script>
JavaScript Regular expression cheat arithmetic batch do problem pupils