Want to subscribe to topics you're interested in?
Become a Member

Wordpress WP problem unrelated to cmm, search/replace regex

Discussion in 'Blogs & CMS usage' started by julliuz, Nov 20, 2019.

  1. julliuz

    julliuz Member

    Dec 20, 2018
    Local Time:
    11:22 AM
    Hi there

    I've been looking far and wide and haven't found a solid solution for this yet, maybe someone could help me here.

    I have a website with a lot of videos (hundreds) and they are all played with fluid player and posted with [fluid player link: etc] brackets that makes the player appear and play the clip.

    within the brackets is a line that says: vast_file="xxx" , which loads whatever is within the quotation marks as a preroll vast video ad.

    A recent fuckup has made it so the vast file is scattered all over the place and I can no longer simply search and replace the link that is within the quotation marks and replace it with another one .

    Is there any way to lookup and change every link that is between vast_file"*" with a wildcard ? and change it to 1 link ? So it would lookup vast_file" and change whatever is between quotation marks ?

    Thank you

    preferrable in regex (which is useable with a wp plugin)
    Last edited: Nov 20, 2019
  2. eva2000

    eva2000 Administrator Staff Member

    May 24, 2014
    Brisbane, Australia
    Local Time:
    7:22 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    What about wp-cli search and replace mentioned at Wordpress - centmin.sh menu option 22 - How to switch Wordpress to subdirectory. The wp-cli tool is installed via centmin.sh menu option 22 wordpress auto installer routine already.

    Documentation at wp search-replace | WordPress Developer Resources.

    Probably want to test it on a copy of your MySQL database or backup your MySQL database before trying and/or use --dry-run flag first to check

    Code (Text):
    # Search and replace but skip one column
    $ wp search-replace 'http://example.test' 'http://example.com' --skip-columns=guid
    # Run search/replace operation but dont save in database
    $ wp search-replace 'foo' 'bar' wp_posts wp_postmeta wp_terms --dry-run
    # Run case-insensitive regex search/replace operation (slow)
    $ wp search-replace '\[foo id="([0-9]+)"' '[bar id="\1"' --regex --regex-flags='i'
    # Turn your production multisite database into a local dev database
    $ wp search-replace --url=example.com example.com example.test 'wp_*options' wp_blogs
    # Search/replace to a SQL file without transforming the database
    $ wp search-replace foo bar --export=database.sql
    # Bash script: Search/replace production to development url (multisite compatible)
    if $(wp --url=http://example.com core is-installed --network); then
       wp search-replace --url=http://example.com 'http://example.com' 'http://example.test' --recurse-objects --network --skip-columns=guid --skip-tables=wp_users
       wp search-replace 'http://example.com' 'http://example.test' --recurse-objects --skip-columns=guid --skip-tables=wp_users