Gayathri Srinivasan edited untitled.tex  over 8 years ago

Commit id: 5e18736fad5f5198cafe1a9a1a988bd7ab1ccf7b

deletions | additions      

       

if (sentence.indexOf("Sam")!=-1)  alert("Sam is in there!")  \subsubsection{LastIndexof():}  Searches and (if found) returns the index number of the searched character or substring within the string. Searches the string from end to beginning. If not found, -1 is returned. “Start” is an optional argument specifying the position within string to begin the search. Default is string.length-1.  //lastIndexOf(substr, [start])  var myString = 'javascript rox';  console.log(myString.lastIndexOf('r'));  //output: 11  \subsubsection{Match():}  Executes a search for a match within a string based on a regular expression. It returns an array of information or null if no match is found.  //match(regexp) //select integers only  var intRegex = /[0-9 -()+]+$/;   var myNumber = '999';  var myInt = myNumber.match(intRegex);  console.log(isInt);  //output: 999  var myString = '999 JS Coders';  var myInt = myString.match(intRegex);  console.log(isInt);  //output: null