Mega Code Archive

 
Categories / JavaScript Tutorial / String
 

Separator With Limit of 2

< html>     <script language="JavaScript1.2">     <!--     function genResults(arrayName, testName){       document.write('<b>Currently Evaluating: ' + testName + '</b><hr>');       if(arrayName == null){         document.write('No matches were found');       }else{         for(var i = 0; i < arrayName.length; i++){           document.write('[' + i + ']: ' + arrayName[i] + '<br>');         }       }       document.write('<P>');     }     var myString = new String("This is a test");     var myRegExp = /\s/g;     var mySeparator = " ";     genResults(myString.split(mySeparator, 2), "Separator With Limit of 2");     document.close();     -->     </script> </html>