Skip to content

Commit

Permalink
Merge pull request #36 from CWolfs/bugfix/EC-35-fixed-aggressive-inte…
Browse files Browse the repository at this point in the history
…rpolation-regex

Fixed too aggressive regex interpolation
  • Loading branch information
CWolfs authored Oct 11, 2022
2 parents 9ef8c30 + 89bf912 commit 1f5b7c2
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Core/ConversationInterpolator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("\\<Stats.*?\\>");
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();
Expand Down Expand Up @@ -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}";
}
}
}
}
}

0 comments on commit 1f5b7c2

Please sign in to comment.