From ae5d7ccb519050c8daf9836578c611b4b5a823f5 Mon Sep 17 00:00:00 2001 From: Haoming Date: Wed, 12 Nov 2025 17:19:46 +0800 Subject: [PATCH] wildcard --- javascript/prompt_format.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/javascript/prompt_format.js b/javascript/prompt_format.js index 595ce59..ba06d9e 100644 --- a/javascript/prompt_format.js +++ b/javascript/prompt_format.js @@ -206,11 +206,11 @@ class LeFormatter { static #rmUnderscore(input) { if (!input.trim()) return ""; - for (let i = 0; i < this.#cards.length; i++) input = input.replaceAll(this.#cards[i], `@TEXTUAL${i}INVERSION@`); + for (let i = 0; i < this.#cards.length; i++) input = input.replaceAll(this.#cards[i], `@T${i}I@`); - input = input.replaceAll("_", " "); + input = input.replace(/(^|[^_])_([^_]|$)/g, "$1 $2"); - for (let i = 0; i < this.#cards.length; i++) input = input.replaceAll(`@TEXTUAL${i}INVERSION@`, this.#cards[i]); + for (let i = 0; i < this.#cards.length; i++) input = input.replaceAll(`@T${i}I@`, this.#cards[i]); return input; }