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

标签 oracle plsql oracle12c

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* 这里只是删除只包含空格字符的行。

关于oracle - 如何删除或跳过字符串中的多个新行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63383910/

相关文章:

java - pl/sql java源码类错误javax.xml.transform.TransformerConfigurationException : Could not compile stylesheet

oracle - 为什么我得到 ORA-39001 : invalid argument value when I try to impdp in Oracle 12c?

json - 如何使用 Oracle 12c 获取存储为 CLOB 的 JSON 数组中的元素数量?

c - 错误 LNK2001 : unresolved reference with Pro*C code with Visual C++

sql - 数百个别名/同义词与数据库表的完全限定名称

sql - SQL查询的过程需要(Oracle)

java - jdbc中连接对象Con的范围

oracle - Oracle 中带有子查询的 TRUNC(date)

oracle - oracle 过程中的某些 ID 不显示数据

oracle - 保存 PL/SQL 异常并稍后引发它?