From 79a135068f76f0062c1b2905fc531062124383f8 Mon Sep 17 00:00:00 2001 From: yusufhay <32195740+yusufhay@users.noreply.github.com> Date: Thu, 7 May 2026 04:25:13 +0530 Subject: [PATCH] Document empty replacement values --- README.md | 6 +++++- src/Search_Replace_Command.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bcd6d4b0..082c9653 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,8 @@ the Key column. [--new=] An alternative way to specify the replacement string. Use this when the - replacement string starts with '--' (e.g., --new='--other-text'). + replacement string starts with '--' (e.g., --new='--other-text') or is + empty. [--dry-run] Run the entire search/replace operation and show report, but don't save @@ -158,6 +159,9 @@ the Key column. # Search/replace string containing hyphens $ wp search-replace --old='--old-string' --new='new-string' + # Remove a string by replacing it with an empty value + $ wp search-replace --old='remove-me' --new='' + # Use precise mode for complex serialized data $ wp search-replace 'oldurl.com' 'newurl.com' --precise diff --git a/src/Search_Replace_Command.php b/src/Search_Replace_Command.php index 8423560d..cae8e86c 100644 --- a/src/Search_Replace_Command.php +++ b/src/Search_Replace_Command.php @@ -162,7 +162,8 @@ class Search_Replace_Command extends WP_CLI_Command { * * [--new=] * : An alternative way to specify the replacement string. Use this when the - * replacement string starts with '--' (e.g., --new='--other-text'). + * replacement string starts with '--' (e.g., --new='--other-text') or is + * empty. * * [--dry-run] * : Run the entire search/replace operation and show report, but don't save @@ -275,6 +276,9 @@ class Search_Replace_Command extends WP_CLI_Command { * # Search/replace string containing hyphens * $ wp search-replace --old='--old-string' --new='new-string' * + * # Remove a string by replacing it with an empty value + * $ wp search-replace --old='remove-me' --new='' + * * # Use precise mode for complex serialized data * $ wp search-replace 'oldurl.com' 'newurl.com' --precise *