From 89bf912cdecdf0a9878a6b607ebfc12a279fa085 Mon Sep 17 00:00:00 2001 From: Richard Griffiths Date: Tue, 11 Oct 2022 23:08:28 +0200 Subject: [PATCH] Fixed too aggressive regex interpolation --- src/Core/ConversationInterpolator.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Core/ConversationInterpolator.cs b/src/Core/ConversationInterpolator.cs index 6cc286e..0ce4664 100644 --- a/src/Core/ConversationInterpolator.cs +++ b/src/Core/ConversationInterpolator.cs @@ -21,17 +21,17 @@ public ConversationInterpolator() { public string Interpolate(string text) { // Main.Logger.Log($"[InterpolateStats] text '{text}'"); - Regex regex = new Regex("\\<.*?\\>"); + Regex regex = new Regex("\\"); MatchCollection matchCollection = regex.Matches(text); - while (matchCollection.Count > 0) { - Match match = matchCollection[0]; - string value = match.Value; - string expression = null; - if (value.Length > 2) { - expression = value.Substring(1, value.Length - 2).Trim(); - } - int index = match.Index; - int length = match.Length; + while (matchCollection.Count > 0) { + Match match = matchCollection[0]; + string value = match.Value; + string expression = null; + if (value.Length > 2) { + expression = value.Substring(1, value.Length - 2).Trim(); + } + int index = match.Index; + int length = match.Length; string[] lookups = expression.Split('.'); string actionType = lookups[0].ToLower(); @@ -69,7 +69,7 @@ private string InterpolateStats(string text, string[] lookups) { } else { Main.Logger.LogError($"[InterpolateStats] Stat '{statName}' does not exist for stat collection '{statType}'"); return $"[InterpolateStats] Stat {statName} does not exist for stat collection {statType}"; - } + } } } } \ No newline at end of file