I am trying to use wp cli (with regex) to search and replace.
I want to change:
So I want to get rid of the "asdnbahsdjhgzw" part.
Now I tried something like:
wp search-replace "domain.com/wp-content/uploads/(\d)/(\d)/(\d*)/" "domain.com/wp-content/uploads/\$1/\$2/" --precise --all-tables --skip-columns=guid --regex
- (\d)/(\d)/ to match and "capture" the directory structure for media and thought I would be able to call them back in the replacement with /$1/$2/.
- (\d*)/ is to capture the random directory name, asdnbahsdjhgzw/, and don't call it back in the replacement.
Unfortunately, this isn´t working as I had hoped. I get the following error:
syntax error near unexpected token `('
I also tried the backslash before the (
But no luck.
Perhaps someone knows what could be the issue, apart from me not knowing WP CLI ;)