WordPress.org

Ready to get started?Download WordPress

Forums

Search And Replace Query (3 posts)

  1. planetphillip
    Member
    Posted 7 years ago #

    Hi,

    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?

    TIA

  2. Austin Matzko
    Member
    Posted 7 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
    Member
    Posted 7 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