Update component imports and add conditional focus in PlaygroundForm

This commit is contained in:
n4ze3m
2024-03-03 23:30:42 +05:30
parent 0351beeaae
commit a87c56061c
12 changed files with 180 additions and 25 deletions

View File

@@ -0,0 +1,24 @@
export const getVariable = (text: string) => {
const regex = /{([^}]+)}/g;
let data : {
word: string,
start: number,
end: number
} | null = null;
let m: RegExpExecArray | null;
while ((m = regex.exec(text)) !== null) {
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
data = {
word: m[1],
start: m.index,
end: m.index + m[0].length
}
}
return data;
}