@snipsonian/core
Version:
Core/base reusable javascript code snippets
20 lines (18 loc) • 477 B
text/typescript
export default function getPartBetween({
firstPart,
secondPart,
input,
}: {
firstPart: string;
secondPart: string;
input: string;
}): string {
try {
return getPartAfter({ separator: firstPart, input }).split(secondPart)[0];
} catch (e) {
return undefined;
}
}
function getPartAfter({ separator, input }: { separator: string; input: string }): string {
return input.substr(input.indexOf(separator) + separator.length);
}