【发布时间】:2020-12-05 06:51:09
【问题描述】:
我正在尝试从 oracle 11g 中的数据库列中获取特定数据,但我的正则表达式只返回第一次出现的数据。知道如何获得由“|”分隔的同一行中的所有事件吗??
我的查询:
SELECT regexp_substr(
'"Error:" {user_1@domain.com}<"User_2" {user_2@domain.com};"Error:" {user_3@domain.com}<"User_4" {user_4@domain.com};',
'Error:[^<]+<'
) AS emails
FROM DUAL;
我的输出应该是:
Error:" {user_1@domain.com}< Error:" {user_3@domain.com}<
当前输出为:
Error:" {user_1@domain.com}<
为了清楚起见,我在我的表中附加了插入语句的 dml:
insert into tests(result) values ('</span></td></tr><tr><td><span class="inputlabel">[14].</span>  <span class="label">ORC|Boston Medical Center|||||||||||||
</span></td></tr><tr><td><span class="inputlabel">[15].</span>  <span class="label">OBR|05-123|LOINC-Lcl-11546-9-1|20050415||||||||||LocalCode: Abscess2||||c|||||
</span></td></tr><tr><td class="errorlabel" nowrap>Error: Report Status Code (ReportStatusCode of type ID) value (c) is invalid Vocabulary code.</td></tr><tr><td class="errorlabel" nowrap>Message rejected.</td></tr><tr><td><span class="inputlabel">[17].</span>  <span class="label">PID||||||||RecCtl_ID|FORTES|AVERY||||||||||||||||||
</span></td></tr><tr><td><span class="inputlabel">[18].</span>  <span class="label">NK1|NK Last Name|NK First Name||||||||||
</span></td></tr><tr><td><span class="inputlabel">[19].</span>  <span class="label">ORC|Boston Medical Center|||||||||||||
</span></td></tr><tr><td><span class="inputlabel">[20].</span>  <span class="label">OBR|05-123|LOINC-Lcl-11546-9-1|20050415||||||||||Local 128477000||||Report_Status_Code 12345678_30|||||
</span></td></tr><tr><td><span class="inputlabel">[21].</span>  <span class="label">OBX|LOINC-Lcl-11546-9-4|SMED-Lcl-78181009-4|||||F|200504231010|BMC
</span></td></tr><tr><td class="inputlabel" nowrap>Processing Results: 3 Messages Accepted, <span class="errorlabel">1 Messages Rejected.</span></td></tr><tr><td class="inputlabel" nowrap>End Time: 2011-08-07 18:47:47.312</td></tr></table>
</span></td></tr><tr><td class="errorlabel" nowrap>Error: Report Status Code (ReportStatusCode of type ID) value (c) is invalid Vocabulary code.</td></tr><tr><td class="errorlabel" nowrap>Message rejected.</td></tr><tr><td><span class="inputlabel">[17].</span>  <span class="label">PID||||||||RecCtl_ID|FORTES|AVERY||||||||||||||||||
')
表创建:
create table TESTS
(
result CLOB
)
现在我想要来自上述 HTML 的所有错误消息,即输出应该是这样的:
Error: Report Status Code (ReportStatusCode of type ID) value (c) is invalid Vocabulary code Error: Report Status Code (ReportStatusCode of type ID) value (c) is invalid Vocabulary code
现在我只收到 1 条错误消息。
【问题讨论】:
标签: sql regex oracle11g regex-lookarounds