I have quite a few old posts that contain an img tag with height and width with no double quotes around the numbers. For example:
<img height=319 alt="" src="http://www.example.com/images/myexample.jpg" width=496>
I am not sure how to write a MySQL query that can find the height and width numbers, and surround them with double quotes.
Although a MySQL query is preferred, if this is not possible then perhaps someone could suggest a regular expression I could use with a PHP script that might solve this issue.
You are simply going to love this one
First of all, here is a sample table with data loaded:
You must run two queries one after the other:
This one puts doublequotes around the number height
This one puts doublequotes around the number width
Watch what happens when I run these and show table contents:
Give it a Try !!!
CAVEAT
Here’s your started for 10…
You can use the REGEXP operator in a MySQL query, then do an update on the returned results.
The regular expression you need will be something like:
So you’re query will be something like:
The reason I’m using the terminology “something like” is that i can not test this on a database.
Further reading for you:
http://www.regular-expressions.info/mysql.html
Hope this helps.