0
我想在给定模式之前查找文本。我的主要问题是当我的文本有很多行时。regexp_substr:在给定模式之前查找文本
在这里,例如:
SQL> with foo as
2 (select '1 first test error log blabla ' k from dual
3 union
4 select '2 second test
5 zz error log blablabla ' k from dual
6 )
7 SELECT REGEXP_SUBSTR(k,'.*error log',1,1) AS result_
8 ,k from foo;
RESULT_ K
------------------------------------- -------------------------------------
1 first test error log 1 first test error log blabla
zz error log 2 second test
zz error log blablabla
结果是用于第二行假。 它应该是:
RESULT_ K
------------------------------------- -------------------------------------
1 first test error log 1 first test error log blabla
2 second test 2 second test
zz error log zz error log blablabla
我跑11.2 Oracle数据库
打我吧。在oracle中使用'n',然而,大多数语言的标志是's'。 – ctwheels
您好MTO,谢谢您的回答。这正是我想要的。我只是要添加到我的查询。这是不正确的,因为正则表达式是贪婪的。所以为了避免这种情况,如果我们有两次模式,我们可以添加一个?到搜索。它将是REGEXP_SUBSTR(k,'。*?错误日志',1,1,'n') – eliatou