[plug] Stripping out Markups in SQL
Trevor Phillips
T.Phillips at murdoch.edu.au
Fri Aug 30 14:34:29 WST 2002
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('>',RESOURCE.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;
--
. Trevor Phillips - http://jurai.murdoch.edu.au/ .
: Web Technical Administrator - T.Phillips at murdoch.edu.au :
| IT Services - Murdoch University |
>--------------------------------------------------------------------<
| On nights such as this, evil deeds are done. And good deeds, of /
| course. But mostly evil, on the whole. /
\ -- (Terry Pratchett, Wyrd Sisters) /
More information about the plug
mailing list