Using wp-cli and delete everypost first image

According to the WP-CLI docs for the wp search-replace command (and wp db search, for that matter), you have to pass your search string without delimiters and pass any flags separately.

Instead of:

wp search-replace '/<img[^>]+\>/i' '' wp_posts --regex --allow-root

You would use something more like this:

wp search-replace '<img[^>]+\>' '' wp_posts --regex --allow-root --regex-flags="i" --regex-delimiter="https://wordpress.stackexchange.com/"

I just tested this on an install and I’m getting plenty of results.

Edit: WP-CLI indeed does not yet support some sort of limit parameter to only replace the first occurrence. However, I opened an issue for it so it might be possible in the future.