如果它在 pl/sql 中,那么你可以这样做:
SQL> declare
2 v_str varchar2(2000) := 'start1
3 david@gmail.com
4 david@gmail.com
5 david@gmail.com
6 david@gmail.com
7 david@gmail.com
8 david@gmail.com
9 david@gmail.com
10 start2';
11 v_newstr varchar2(2000);
12 v_start_delim varchar2(10) := 'start1';
13 v_end_delim varchar2(10) := 'start2';
14 begin
15 v_newstr := substr(v_str, instr(v_str, v_start_delim)+length(v_start_delim),
16 instr(v_str, v_end_delim) - instr(v_str, v_start_delim) - length(v_start_delim));
17
18 -- remove leading/trailing breaks.
19 v_newstr := trim(both chr(10) from v_newstr);
20 dbms_output.put_line(v_newstr);
21
22 end;
23 /
david@gmail.com
david@gmail.com
david@gmail.com
david@gmail.com
david@gmail.com
david@gmail.com
david@gmail.com
PL/SQL procedure successfully completed.
或者如果您在 SQL 中有字符串(假设字符串都在一行中)
SQL> select trim(both chr(10) from
2 substr(str, instr(str, 'start1')+length('start1'),
3 instr(str, 'start2') - instr(str, 'start1') - length('start1'))
4 ) newstr
5 from data;
NEWSTR
-----------------------
david@gmail.com
david@gmail.com
david@gmail.com
david@gmail.com
david@gmail.com
david@gmail.com
david@gmail.com