With WP CLI I can use the search-replace method like this:
wp search-replace 'foo' 'bar'
However, when I use regex, it only replaces the first occurrence within each DB field:
wp search-replace 'myRegex' 'bar' --regex
In the above example, only the first regex match for myRegex
is replaced in any given DB field. I can repeatedly run the search over and over until all matches have been replaced, but I'd like to be able to do it in one command. The /g global flag is not available because when I try it:
wp search-replace 'myRegex/g' 'bar' --regex
I get a bunch of warnings that I cannot use it with php preg_replace:
PHP Warning: preg_replace(): Unknown modifier 'g'