【发布时间】:2019-12-04 00:11:48
【问题描述】:
当某些字符出现在字符串中时尝试限制响应- 即我想要“牛去散步” 不过
1 if within 20 characters the word 'BAD' appears such as the "The BAD mean cow went for a walk" it would return a null value
2. The same if there was punctuation in the middle of the sentence, so that
"The cow came back. But the dog went for a walk" would not return a value-
代码如下。
with test (id, col) as (
select 1, 'The cow went for a walk' from dual union all --want this
select 2, 'The BAD mean cow went for a walk' from dual union all --do not want this
select 3, 'The cow came back. But the dog went for a walk' from dual) --do not want this
select id, col,
regexp_substr(col,'(cow).{1,40}(walk)',1,1,'i') rs
regexp_substr(col,'(cow).{1,40}(([^.])(walk))',1,1,'i') rs2
from test
RS2 是我第一次尝试限制响应,但没有成功。
【问题讨论】:
标签: sql regex oracle case regexp-substr