regex
parent
e933ae0fb2
commit
33b9886431
|
|
@ -57,3 +57,6 @@ Sometimes, when you type too fast or copy prompts from all over the places, you
|
||||||
```
|
```
|
||||||
- When you type `girl`, it will get converted into `1girl`
|
- When you type `girl`, it will get converted into `1girl`
|
||||||
- Which will get removed if the prompt already contains `1girl`
|
- Which will get removed if the prompt already contains `1girl`
|
||||||
|
|
||||||
|
> [!Note]
|
||||||
|
> The pattern will be wrapped in `^(regex)$`
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,15 @@ class pfConfigs {
|
||||||
|
|
||||||
for (const line of config.split("\n")) {
|
for (const line of config.split("\n")) {
|
||||||
const [tag, words] = line.split(":");
|
const [tag, words] = line.split(":");
|
||||||
const pattern = new RegExp(words);
|
const pattern = this.#parseRegExp(words);
|
||||||
alias.set(pattern, tag);
|
alias.set(pattern, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return alias;
|
return alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param {string} input @returns {RegExp} */
|
||||||
|
static #parseRegExp(input) {
|
||||||
|
return new RegExp(`^(${input})$`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue