JSFiddle - React, Tailwind, and code Playground
by OriginalEXE
JavaScript
function sequenceMatchCount( collection, pattern ) {
var count = 0;
if ( ! collection.length ) {
return count;
}
for ( i = 0; i < collection.length; i++ ) {
var val = collection[ i ];
if ( 'string' !== typeof val ) {
continue;
}
var simplifiedVal = val.replace( /([A-Z])\1+/gi, '$1' );
if ( pattern === simplifiedVal ) {
count++;
}
}
return count;
}
var testArray = [ 'abc', 'ab', 'ad', 'ac', 'abbc', 'aaabc' ],
testSequence = 'abc';
document.body.innerHTML = sequenceMatchCount( testArray, testSequence );