搜索完整的模式,然后Group
在该模式的子字符串中搜索单词。如果文本中有多个匹配项,那么您可以使用递归子查询因式分解子句来查找它们:
甲骨文设置:
CREATE TABLE table_name ( id, text ) AS
select 1, '<a href Part of the technical Network Group www.tech.com/sites/ hh a>' from dual union all
select 2, '<a href www.tech.technical Network a>' from dual union all
select 3, 'www.tech.tech///technical <a href Network Group a>' from dual union all
select 4, '<a hrefgroup a>' FROM DUAL UNION ALL
select 5, '<a href groupa>' FROM DUAL UNION ALL
select 6, '<a href workgroup a>' FROM DUAL UNION ALL
select 7, '<a href test1 a> Group <a href test2 a>' FROM DUAL;
查询:
WITH positions ( id, text, match, position ) AS (
SELECT id,
text,
REGEXP_SUBSTR(
text,
'(^|\W)<a href\s+.*?\s+a>(\W|$)',
1,
1,
'i'
),
REGEXP_INSTR(
text,
'(^|\W)<a href\s+.*?\s+a>(\W|$)',
1,
1,
0,
'i'
)
FROM table_name
UNION ALL
SELECT id,
text,
REGEXP_SUBSTR(
text,
'(^|\W)<a href\s+.*?\s+a>(\W|$)',
position + 1,
1,
'i'
),
REGEXP_INSTR(
text,
'(^|\W)<a href\s+.*?\s+a>(\W|$)',
position + 1,
1,
0,
'i'
)
FROM positions
WHERE position > 0
)
SELECT id,
text
FROM positions
WHERE REGEXP_LIKE( match, '\sGroup\s', 'i' );
输出:
身份证 | 文本
-: | :------------------------------------------------ ------------------
1 | <a href 属于技术网络组 www.tech.com/sites/ hh a>
3 | www.tech.tech///technical <a href 网络组 a>
db<>在这里摆弄