@anupam.bharti/findinstring

Search in a string and find all occurance count with indexes

Usage no npm install needed!

<script type="module">
  import anupamBhartiFindinstring from 'https://cdn.skypack.dev/@anupam.bharti/findinstring';
</script>

README

Install

Install with npm:

$ npm install @anupam.bharti/findinstring

Usage

const findme = require('@anupam.bharti/findinstring');

var toSearchArr = ['a', 'e', 'o', 'i', 'u'];
let str = 'This is Sample string to be searched';

let res = findme(str, toSearchArr, 1); // third argument pass 1 if you want case sensitive search

console.log(res);

Will Output : 

{ 
  count: [ a: 2, e: 4, o: 1, i: 3 ],
  indexes:
   [ a: [ 9, 30 ],
     e: [ 13, 26, 29, 34 ],
     o: [ 23 ],
     i: [ 2, 5, 18 ] ] 
}