Networking • Automation • Occasional Podcasting
,

Replace String in Mysql

I switched to a new wordpress code highlight plugin, so I had to replace the old highlight string with a new. I issued 3 SQL commands that crawled my posts and updated them.

update wp_posts set post_content = replace(post_content, ‘<code lang="text">’, ‘<p lang="text" line="1">’);
update wp_posts set post_content = replace(post_content, ‘<code>’, ‘<p lang="text" line="1">’);
update wp_posts set post_content = replace(post_content, ‘</code>’, ‘</p>’);
replace(field_name, ‘find string’, ‘replace string’);

Here’s the MySQL doc.

Comments

13 responses to “Replace String in Mysql”

  1. N.R. Avatar

    ugly, why change from to :(

    Code is poetry, and you just turned into hiphop :)

  2. N.R. Avatar

    damn, your comment engine just removed all my tags

  3. Greg Avatar

    😛 hehehehe

  4. N.R. Avatar

    I just wanted to say that using the code tag is way much better than using a P tag with a class.

  5. Rob Avatar
    Rob

    I prefer the PRE tag over both CODE or P to help maintain formatting. Works especially well where indentation is important such as python. I guess a CSS class for a P tag could be constructed similar but PRE is already available so why not use that?

  6. Greg Avatar

    Agreed. When I upgraded to the new version of WP, there were on a couple of options, so I chose this one. When you don’t have options, you choose the lesser evil. 🙂

  7. Greg Avatar

    That joke was so bad I think a little part of me just died…actually I think it was so bad, an angel lost its wings.

  8. Jimmy Avatar

    Apparently you aren’t a big Master and Commander fan….

  9. Greg Avatar

    Never seen it, and with jokes like that…I’m pretty sure I don’t want to…hehe.

  10. Jimmy Avatar

    [Dinner in the officers’ mess. The captain is inebriated, but asks apparently seriously]
    Capt. Jack Aubrey: Do you see those two weevils doctor?
    Dr. Stephen Maturin: I do.
    Capt. Jack Aubrey: Which would you choose?
    Dr. Stephen Maturin: [sighs annoyed] Neither; there is not a scrap a difference between them. They are the same species of Curculio.
    Capt. Jack Aubrey: If you had to choose. If you were forced to make a choice. If there was no other response…
    Dr. Stephen Maturin: [Exasperated] Well then if you are going to *push* me…
    [the doctor studies the weevils briefly]
    Dr. Stephen Maturin: …I would choose the right hand weevil; it has… significant advantage in both length and breadth.
    [the captain thumps his fist in the table]
    Capt. Jack Aubrey: There, I have you! Your completely dished! Do you not know that in the service…
    [pauses]
    Capt. Jack Aubrey: …one must always choose the lesser of two weevils.
    [the officers burst out in laughter]

  11. N.R. Avatar

    Well, pre just makes sure you don’t break your tags and line breaks, code actually incicates that it’s code, and helps to format it accordingly. the most correct way is to use them both:

    http://www.w3.org/TR/html5/semantics.html#the-pre-element

  12. Greg Avatar

    Normis,

    I commend you for wanting to do what’s right…but, that doesn’t always happen 😉

Leave a Reply

Your email address will not be published. Required fields are marked *