如何删除或跳过字符串中的多个新行?

How to remove or skip the multiple new line in string?

DECLARE
   v_string VARCHAR2(4000) := 'A database is an organized collection of data, 
   generally stored and accessed electronically 
   from a computer system. Where databases are more
  
  
   
  complex they are often developed 
  using formal design and modeling techniques.';
   v_sql_code_new VARCHAR2(4000);
BEGIN
END;
 /  

  Desired output: 
     A database is an organized collection of data, 
     generally stored and accessed electronically 
     from a computer system. Where databases are more
     complex they are often developed 
     using formal design and modeling techniques.

我正在尝试从字符串中删除所有换行符。我尝试使用 regexp_replace 但无法获得所需的结果。 提前谢谢你

虽然你也可以使用'^\s*$'modifier=>'mn',最简单的方法是替换多个chr(10):

DECLARE
   v_string VARCHAR2(4000) := 'A database is an organized collection of data, 
   generally stored and accessed electronically 
   from a computer system. Where databases are more
  
  
   
  complex they are often developed 
  using formal design and modeling techniques.';
   v_sql_code_new VARCHAR2(4000);
BEGIN
   dbms_output.put_line(regexp_replace(v_string,chr(10)||'(\s*'||chr(10)||')+',chr(10)));
END;
/

\s* 这里只是删除仅包含 space 个字符的行。