Reputation: 311
I have a string like this in my column:
<p>[img ret872154ftu] fileaddress [/img ret872154ftu]</p>
<p>[img fd68721cvn] fileaddress [/img fd68721cvn]</p>
<p>[img xdfh654t] fileaddress [/img xdfh654t]</p>
Now i wish to remove unwanted chars inside [img] and [/img]. I have already used this query but does not work:
UPDATE `table` SET `content` = replace(`content`, '[img [^]*]', '[img]');
Any suggestion?
Upvotes: 1
Views: 655
Reputation: 26804
UPDATE table SET
column=REPLACE(column,SUBSTRING_INDEX(SUBSTRING_INDEX(column,'/img ',-1),']',1),'');
UPDATE table SET
column=REPLACE(column,SUBSTRING_INDEX(SUBSTRING_INDEX(column,'[img ',-1),']',1),'');
2 updates,with different delimiters because the texts might be different.
Upvotes: 3