From b01a3696a0b924ee9073841d66685bae0ddc2865 Mon Sep 17 00:00:00 2001 From: Minhyeok Park Date: Sat, 1 Feb 2025 10:06:13 +0900 Subject: [PATCH] feat(regexp): add index and match indicator --- src/Transforms/RegexpTransform.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Transforms/RegexpTransform.ts b/src/Transforms/RegexpTransform.ts index bdce54a..64752f9 100644 --- a/src/Transforms/RegexpTransform.ts +++ b/src/Transforms/RegexpTransform.ts @@ -8,7 +8,10 @@ export const RegexpTransform: Transform = { const parsedSamples = samples .split('\n') - .map((sample) => JSON.stringify(regexp.exec(sample)?.groups)) + .map((sample) => regexp.exec(sample)) + .map((sample, i) => + `${i + 3}(${sample === null ? 'x' : 'o'}) ${JSON.stringify(sample?.groups) ?? ''}`.trimEnd() + ) .join('\n') return [expression, samples, parsedSamples].join('\n\n')