From 82f5e6ffd52cc389c3b2689eef2a3b805204744c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Sat, 16 Feb 2019 14:17:28 +0100 Subject: [PATCH] Use non-greedy search in template matching --- card-tools.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/card-tools.js b/card-tools.js index e1e3868..40abf3f 100644 --- a/card-tools.js +++ b/card-tools.js @@ -240,7 +240,8 @@ class { static parseTemplate(text, error) { if(typeof(text) !== "string") return text; - var RE_template = /\[\[\s(.*)\s\]\]/g; + // Note: .*? is javascript regex syntax for NON-greedy matching + var RE_template = /\[\[\s(.*?)\s\]\]/g; text = text.replace(RE_template, (str, p1, offset, s) => this.parseTemplateString(p1)); return text; }