如何始终使用正则表达式检查单词是否是从 www 开始的字符串的一部分?
How to check if the word is a part of the string starting from www always using regex?
我有一个文本值,每个文本中都有一个 URL 作为它的一部分。如何识别技术一词是否属于 link?
create table t as
select 'Part of the technical Network Group www.technical.com/sites/' as text from dual
union select 'Technical Network Group' as text from dual;
select * from t
where regexp_like(text,'technical','i')
我收到了这两个文本。我只需要第一个文本。 link 可能不同,它也可以是 www.tech.technical。
你可以使用@Wiktor 在评论中建议的东西
select * from t
where regexp_like(text,'www\..*technical','i')
这里是 SQLFiddle 中的示例。但是学习 Regex 会更好,因为您可以找到的 url 可能会大不相同。
您可以使用
WHERE REGEXP_LIKE(text,'www\.\S*technical','i')
或者,如果你也想考虑URL可以从http
或https
开始,
WHERE REGEXP_LIKE(text,'(https?://|www\.)\S*technical','i')
详情
www\.
- www.
子串
\S*
- 除空格外的 0+ 个字符
technical
- technical
子串。
with testdata(text) as (
select 'Part of the technical Network Group www.technical.com/sites/' from dual
union
select 'Part of the technical Network Group www.some.com/sites/technical' from dual
union
select 'Technical Network Group' from dual
)
select * from testdata where regexp_like(text,'www\.\S*technical','i')
输出:
见 another demo http
/https
支持。
我有一个文本值,每个文本中都有一个 URL 作为它的一部分。如何识别技术一词是否属于 link?
create table t as
select 'Part of the technical Network Group www.technical.com/sites/' as text from dual
union select 'Technical Network Group' as text from dual;
select * from t
where regexp_like(text,'technical','i')
我收到了这两个文本。我只需要第一个文本。 link 可能不同,它也可以是 www.tech.technical。
你可以使用@Wiktor 在评论中建议的东西
select * from t
where regexp_like(text,'www\..*technical','i')
这里是 SQLFiddle 中的示例。但是学习 Regex 会更好,因为您可以找到的 url 可能会大不相同。
您可以使用
WHERE REGEXP_LIKE(text,'www\.\S*technical','i')
或者,如果你也想考虑URL可以从http
或https
开始,
WHERE REGEXP_LIKE(text,'(https?://|www\.)\S*technical','i')
详情
www\.
-www.
子串\S*
- 除空格外的 0+ 个字符technical
-technical
子串。
with testdata(text) as (
select 'Part of the technical Network Group www.technical.com/sites/' from dual
union
select 'Part of the technical Network Group www.some.com/sites/technical' from dual
union
select 'Technical Network Group' from dual
)
select * from testdata where regexp_like(text,'www\.\S*technical','i')
输出:
见 another demo http
/https
支持。