Skip to content
Jan 13 / Greg

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.

1
2
3
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>’);
1
replace(field_name, ‘find string’, ‘replace string’);

Here’s the MySQL doc.

13 Comments

leave a comment
  1. N.R. / Jan 13 2010

    ugly, why change from to :(

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

  2. N.R. / Jan 13 2010

    damn, your comment engine just removed all my tags

  3. Greg / Jan 13 2010

    😛 hehehehe

  4. N.R. / Jan 14 2010

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

  5. Rob / Jan 14 2010

    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 / Jan 14 2010

    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 / Jan 15 2010

    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 / Jan 15 2010

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

  9. Greg / Jan 15 2010

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

  10. Jimmy / Jan 15 2010

    [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. / Jan 18 2010

    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 / Jan 18 2010

    Normis,

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

Leave a Comment

 

*