From fd50054edfa1cde5902e76e9d1683a3ef0b08e27 Mon Sep 17 00:00:00 2001 From: VaDiM Date: Tue, 10 Jun 2025 20:58:21 +0300 Subject: [PATCH] [CLI] Add regex support for splitObject export mode --- AssetStudioCLI/Studio.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/AssetStudioCLI/Studio.cs b/AssetStudioCLI/Studio.cs index d0a2742..f61952f 100644 --- a/AssetStudioCLI/Studio.cs +++ b/AssetStudioCLI/Studio.cs @@ -826,8 +826,10 @@ namespace AssetStudioCLI public static void ExportSplitObjects() { var savePath = CLIOptions.o_outputFolder.Value; - var searchList = CLIOptions.o_filterByName.Value; + var filterList = CLIOptions.o_filterByName.Value; var isFiltered = CLIOptions.filterBy == FilterBy.Name; + var regexMode = CLIOptions.f_filterWithRegex.Value; + var regex = regexMode ? new Regex(filterList[0]) : null; var exportableObjects = new List(); var exportedCount = 0; @@ -840,9 +842,14 @@ namespace AssetStudioCLI { foreach (GameObjectNode j in node.nodes) { - if (isFiltered) + if (isFiltered && regexMode) { - if (!searchList.Any(searchText => j.Text.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0)) + if (!regex.IsMatch(j.Text)) + continue; + } + else if (isFiltered) + { + if (!filterList.Any(str => j.Text.IndexOf(str, StringComparison.OrdinalIgnoreCase) >= 0)) continue; } var gameObjects = new List(); @@ -861,7 +868,9 @@ namespace AssetStudioCLI var log = $"Found {exportableCount} exportable object(s) "; if (isFiltered) { - log += $"that contain {$"\"{string.Join("\", \"", searchList)}\"".Color(Ansi.BrightYellow)} in their Names"; + log += regexMode + ? $"which names match {regex.ToString().Color(Ansi.BrightYellow)} regexp" + : $"that contain {$"\"{string.Join("\", \"", filterList)}\"".Color(Ansi.BrightYellow)} in their names"; } Logger.Info(log); if (exportableCount > 0)