Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find every character string match JavaScript

const sourceStr = 'I learned to play the Ukulele in Lebanon.';
const searchStr = 'le';
const indexes = [...sourceStr.matchAll(new RegExp(searchStr, 'gi'))].map(a => a.index);
console.log(indexes); // [2, 25, 27, 33]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #character #string #match #JavaScript
ADD COMMENT
Topic
Name
4+2 =