From 8d57c3d97e9cf7e0e69db82c432238c4609f13f2 Mon Sep 17 00:00:00 2001 From: CodeDevMLH <145071728+CodeDevMLH@users.noreply.github.com> Date: Thu, 25 Sep 2025 23:02:51 +0200 Subject: [PATCH] update readne --- README.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de11eed..b7b0846 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Below is an overview of its main functionality and usage: - Operations include: - Inserting text before or after specific content. - Replacing old text with new text. + - NEW: Regex support (prefix markers with `re:`) for `before_text`, `after_text`, and `old_text` to handle dynamical hashes (e.g. Jellyfin assets) - Recursively applies changes to files matching specified patterns in the destination directory. 5. **Error and Warning Tracking**: @@ -84,13 +85,17 @@ copy_rules: modification_rules: - file_pattern: "*.js" # Files to modify (supports regex) insert_rules: - - after_text: "search text" # Insert after this text + - after_text: "search text" # Insert after this exact (plain) text insert_text: "new content" - - before_text: "target" # Insert before this text + - before_text: "target" # Insert before this exact (plain) text insert_text: "new content" + - before_text: 're:' # Regex variant + insert_text: "" replace_rules: - - old_text: "original" # Text to replace + - old_text: "original" # Plain substring replacement new_text: "replacement" + - old_text: 're:' + new_text: 're:' ``` ### Running the Script @@ -102,3 +107,18 @@ So for example: ```bash python customize-WebUI.py config.yaml ``` + +### Regex Markers Cheat Sheet +Prefix any marker with `re:` to interpret it as a Python Regex (DOTALL activ): + +Examples: +``` +before_text: 're:' +after_text: 're:data-backdroptype="movie,series,book">' +old_text: 're:this\\.get\("libraryPageSize",!1\),10\);return 0===t\?0:t\|\|100}' +``` + +Notes: +1. Properly escape backslashes (YAML + Regex!) +2. The first match will be used (count=1 for replacement/insertion) +3. Idempotency: The script checks whether the insertion or replacement text already exists to avoid duplicates \ No newline at end of file