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.
ugly, why change from
to :(
Code is poetry, and you just turned into hiphop :)
damn, your comment engine just removed all my tags
😛 hehehehe
I just wanted to say that using the code tag is way much better than using a P tag with a class.
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?
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. 🙂
Lesser of two weevils?
http://media.divinecaroline.com/ext/article_images2/misc/lesser.jpg
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.
Apparently you aren’t a big Master and Commander fan….
Never seen it, and with jokes like that…I’m pretty sure I don’t want to…hehe.
[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]
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
Normis,
I commend you for wanting to do what’s right…but, that doesn’t always happen 😉