CREATE FUNCTION `SPLIT_STR`(
x text,
delim VARCHAR(12),
pos INT
) RETURNS varchar(255) CHARSET utf8
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos),
LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1),
delim, '')
CREATE FUNCTION `GDPR_find_keyword_and_color_them`(qtntext text,keyword nvarchar(50000)) RETURNS text CHARSET utf8
BEGIN
declare ttlkeyword bigint;
declare loopvar bigint;
declare keyword_ nvarchar(1000);
set ttlkeyword=(select count(*) from nsmx_beta4.privacy_policy_keywords);
set loopvar=1;
while(loopvar<ttlkeyword) do
set keyword_=(select SPLIT_STR(keyword,',',loopvar));
if(keyword_!='') then
set qtntext=replace(qtntext,keyword_,concat('<b>',keyword_,'</b>'));
end if;
set loopvar=loopvar+1;
end while;
return qtntext;
END
select GDPR_find_keyword_and_color_them('hello my name is','my,is');
1条答案
按热度按时间mi7gmzs61#
你可以这样试试。这可能会有帮助。
结果是:你好我的名字是