I was trying to replace a mysql string/text field by another. The problem I have is that the text/varchar field contains bbcode with suffix(like [image:sgzarkty] [/image:sgzarkty]), I want to get rid of the ugly suffix so the bbcode looks cleaner(like [image] [/image]). But the problem is, the suffix can be 6-8 characters long, so I cannot just use substring function to strip it. I am thinking that regular expression can help, but how? Heres what I have with substring replacement, can anyone modify it to work with regular expression for any number of characters?
UPDATE
post
SET
posttext = replace( posttext, substring( posttext, locate( '[spoiler', posttext ) , 17 ) , '[spoiler' )
WHERE
LOCATE( '[spoiler', posttext ) >0