@anupam.bharti/findinstring
v1.0.2
Published
Search in a string and find all occurance count with indexes
Downloads
3
Maintainers
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 ] ]
}