From 7119d2897ded46134a834151bb9ac2ad7f10023c Mon Sep 17 00:00:00 2001 From: Matthew Olivo Date: Wed, 24 Jan 2024 20:27:40 -0800 Subject: [PATCH] - Adding count() function to Special Identifier action --- .../Model/Actions/SpecialIdentifierActionModel.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MixItUp.Base/Model/Actions/SpecialIdentifierActionModel.cs b/MixItUp.Base/Model/Actions/SpecialIdentifierActionModel.cs index fed6a7fdb..700edcb9f 100644 --- a/MixItUp.Base/Model/Actions/SpecialIdentifierActionModel.cs +++ b/MixItUp.Base/Model/Actions/SpecialIdentifierActionModel.cs @@ -59,6 +59,15 @@ protected override async Task PerformInternal(CommandParametersModel parameters) } return Task.FromResult(text); }); + replacementText = await this.ProcessStringFunction(replacementText, "count", (text) => + { + string[] splits = text.Split(new char[] { ',' }); + if (splits != null && splits.Length == 2) + { + return Task.FromResult(Regex.Matches(splits[0], splits[1]).Count.ToString()); + } + return Task.FromResult(text); + }); } if (this.ShouldProcessMath)