feat: prompt preset support

This commit is contained in:
Timothy J. Baek 2024-01-02 00:55:28 -08:00
parent 27aa1e964d
commit 69a037257e
4 changed files with 220 additions and 28 deletions

View file

@ -111,3 +111,19 @@ export const checkVersion = (required, current) => {
caseFirst: 'upper'
}) < 0;
};
export const findWordIndices = (text) => {
const regex = /\[([^\]]+)\]/g;
let matches = [];
let match;
while ((match = regex.exec(text)) !== null) {
matches.push({
word: match[1],
startIndex: match.index,
endIndex: regex.lastIndex - 1
});
}
return matches;
};