我玩过,我可以在纯mysql中给你半个解决方案。
使用它后,您可以在单词的任一侧获取字符串。只是不知道如何获取单词而不是整个子字符串。希望它会有所帮助。
select case when (select w.t regexp concat('[[:<:]]', w.v)) = 1
then substr(w.t, 1, locate(w.v, w.t)-1) else null end as 'left_word',
w.v as word,
case when (select w.t regexp concat(w.v, '[[:>:]]')) = 1
then substr(w.t, locate(w.v, w.t)+length(w.v)) else null end as 'right_word'
from (
select "Lorem ipsum dolor sit amet consectetur adipiscing elit." as t, "amet" as v
) as w;
select case when (select w.t regexp concat('[[:<:]]', w.v)) = 1
then substr(w.t, 1, locate(w.v, w.t)-1) else null end as 'left_word',
w.v as word,
case when (select w.t regexp concat(w.v, '[[:>:]]')) = 1
then substr(w.t, locate(w.v, w.t)+length(w.v)) else null end as 'right_word'
from (
select "Lorem ipsum dolor sit amet consectetur adipiscing elit." as t, "elit." as v
) as w;