Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find every character string match JavaScript

function locations(substring,string){
  var a=[],i=-1;
  while((i=string.indexOf(substring,i+1)) >= 0) a.push(i);
  return a;
}

console.log(locations("s","scissors"));
//-> [0, 3, 4, 7]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #character #string #match #JavaScript
ADD COMMENT
Topic
Name
9+9 =