UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

33 lines 1.41 kB
export function splitByHashNumbers(testString, matches) { //Replace any # with link to issue //First find all instances of # and digits // console.log('getStringArrayWithHashNumbers matches: ', matches); //Removed 2022-02-08 let subSpans = []; if (matches === null) { subSpans.push(testString); return subSpans; } let partialString = testString + ''; matches.map((thisMatch, i) => { // console.log('getStringArrayWithHashNumbers partialString: ',partialString); //Removed 2022-02-08 let idx = partialString.indexOf(thisMatch); if (idx === 0) { //This found string at beginning subSpans.push(`${thisMatch}`); partialString = partialString.substring(thisMatch.length); // console.log( `${i} ${thisMatch}`, subSpans, 'idx===0'); //Removed 2022-02-08 } else if (idx > 0) { //This found string after beginning subSpans.push(partialString.substring(0, idx)); subSpans.push(`${thisMatch}`); // console.log( `${i} ${thisMatch}`, subSpans, 'idx>0 '); //Removed 2022-02-08 partialString = partialString.substring(idx + thisMatch.length); } }); if (partialString) { subSpans.push(partialString); } return subSpans; } //# sourceMappingURL=splitHash.js.map