The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Search And Replace Query (3 posts)

  1. planetphillip
    Posted 9 years ago #


    I am trying to searh and replace for certain text within my database but have a small problem.

    The text I need to replace is over two lines and I have tried using the HTML chracter entites and a few other tricks but nothing seems to work.

    Unfortunately I don't think I am able to perform two seperate queries.

    Here is the query text I am using:
    UPDATE wp_posts SET post_content=REPLACE(post_content, '<ul>
    <p></p>', '</ul>');

    As you can see there is a line break after the first <ul>

    Does anybody have any suggestions?


  2. Austin Matzko
    Posted 9 years ago #

    Some combination of newlines and carriage-returns should do it:
    REPLACE(post_content, '<ul>\n\r','</ul>');

    REPLACE(post_content, '<ul>\r\n','</ul>');

    REPLACE(post_content, '<ul>\n','</ul>');

    REPLACE(post_content, '<ul>\r','</ul>');

  3. planetphillip
    Posted 9 years ago #

    Thank you Sir,

    The singular n worked. Saved me doing that manually 1041 times!

Topic Closed

This topic has been closed to new replies.

About this Topic