[plug] Stripping out Markups in SQL

J Michael Gilks gilksjm at iinet.net.au
Sat Aug 31 10:41:45 WST 2002


On Fri, 30 Aug 2002 14:34, Trevor Phillips wrote:
You might try using the replace() function to replace the markup with an 
empty string.
Something like 
SELECT REPLACE("table.name", "<*>", "") 
FROM table 
ORDER BY table.name

Should replace all markups in the recordset. 
Big bad thought, won't display the markups. If you need to see that maybe 
SELECT the resource in full and only display that column.
Hope this helps.
Love
Mike.
> Does anyone know a nice-ish way to strip markups out of a string field in
> MySQL? I need it to sort records by the visible text, where SOME entries
> contain markups (either at the start, or later in the string...)
>
> What I currently have is:
>    IF(LOCATE('<',RESOURCE.TITLE,1)=1 &&
> LOCATE('>',RESOURCE.TITLE,1)>0,SUBSTRING(RESOURCE.TITLE,LOCATE('>',RE
>SOURCE.TITLE,1)+1),RESOURCE.TITLE)
>
> This only works if the Markup is at the start of the string, though...
> I could toy with using both locate positions  to chop out the middle bit,
> but, ugh! It's getting messy. ^_^
>
> And yet, all I want to do is the equivalent of the perl:  s/\<.*?\>//gs;



More information about the plug mailing list